-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(batch): add option to continue processing other group IDs on fai…
…lure in `SqsFifoPartialProcessor` (#2590)
- Loading branch information
1 parent
9def9fa
commit a615c24
Showing
9 changed files
with
414 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
examples/snippets/batch/gettingStartedSQSFifoSkipGroupOnError.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { | ||
SqsFifoPartialProcessor, | ||
processPartialResponseSync, | ||
} from '@aws-lambda-powertools/batch'; | ||
import { Logger } from '@aws-lambda-powertools/logger'; | ||
import type { | ||
SQSEvent, | ||
SQSRecord, | ||
Context, | ||
SQSBatchResponse, | ||
} from 'aws-lambda'; | ||
|
||
const processor = new SqsFifoPartialProcessor(); | ||
const logger = new Logger(); | ||
|
||
const recordHandler = (record: SQSRecord): void => { | ||
const payload = record.body; | ||
if (payload) { | ||
const item = JSON.parse(payload); | ||
logger.info('Processed item', { item }); | ||
} | ||
}; | ||
|
||
export const handler = async ( | ||
event: SQSEvent, | ||
context: Context | ||
): Promise<SQSBatchResponse> => { | ||
return processPartialResponseSync(event, recordHandler, processor, { | ||
context, | ||
skipGroupOnError: true, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.