Skip to content

Feature request: allow SqsFifoPartialProcessor to continue processing other group IDs upon failure #2561

Closed
@dreamorosi

Description

@dreamorosi

Use case

Currently the SqsFifoPartialProcessor part of the Batch Processing utility short-circuits by throwing an error as soon as an item in a batch fails to process. This is done to prevent out-of-order processing.

By default, we will stop processing at the first failure and mark unprocessed messages as failed to preserve ordering. However, this behavior may not be optimal for customers who wish to proceed with processing messages from a different group ID.

We should look into adding this feature.

Solution/User Experience

Customers should be able to pass a skipGroupOnError option

This could be done by either accepting an option object when instantiating the processor, like:

import {
  SqsFifoPartialProcessor,
  processPartialResponseSync,
} from '@aws-lambda-powertools/batch';
import type {
CallableFunction
} from '@aws-lambda-powertools/batch/types';

declare recordHandler = CallableFunction;

const processor = new SqsFifoPartialProcessor({ skipGroupOnError: true });  // <-- New option

export const handler = async (
  event,
  context
) => {
  return processPartialResponseSync(event, recordHandler, processor, {
    context,
  });
};

Or by accepting a new option in the already existing option object accepted by the processPartialResponseSync function, like:

import {
  SqsFifoPartialProcessor,
  processPartialResponseSync,
} from '@aws-lambda-powertools/batch';
import type {
CallableFunction
} from '@aws-lambda-powertools/batch/types';

declare recordHandler = CallableFunction;

const processor = new SqsFifoPartialProcessor();

export const handler = async (
  event,
  context
) => {
  return processPartialResponseSync(event, recordHandler, processor, {
    context,
    skipGroupOnError: true // <-- New option
  });
};

The second one is probably more organic and allows customers additional customizability as they can define the value for skipGroupOnError in the context of a specific invocation, however it will likely require some TypeScript generic type so that it's accepted only when the processor parameter is of type SqsFifoPartialProcessor.

Either way, the value for skipGroupOnError should be saved in the SqsFifoPartialProcessor instance and then taken in account when calling the shortCircuitProcessing method to decide whether to throw or not.

Alternative solutions

N/A

Acknowledgment

Future readers

Please react with 👍 and your use case to help us understand customer demand.

Metadata

Metadata

Assignees

Labels

batchThis item relates to the Batch Processing UtilitycompletedThis item is complete and has been merged/shippedfeature-requestThis item refers to a feature request for an existing or new utility

Type

No type

Projects

Status

Shipped

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions