@@ -131,6 +131,54 @@ public static <R> List<R> batchProcessor(final SQSEvent event,
131
131
return batchProcessor (event , false , handler );
132
132
}
133
133
134
+ /**
135
+ * This utility method is used to processes each {@link SQSMessage} inside received {@link SQSEvent}
136
+ *
137
+ * <p>
138
+ * Utility will take care of calling {@link SqsMessageHandler#process(SQSMessage)} method for each {@link SQSMessage}
139
+ * in the received {@link SQSEvent}
140
+ * </p>
141
+ *
142
+ * <p>
143
+ * If any exception is thrown from {@link SqsMessageHandler#process(SQSMessage)} during processing of a messages,
144
+ * Utility will take care of deleting all the successful messages from SQS. When one or more single message fails
145
+ * processing due to exception thrown from {@link SqsMessageHandler#process(SQSMessage)}
146
+ * {@link SQSBatchProcessingException} is thrown with all the details of successful and failed messages.
147
+ *
148
+ * </p>
149
+ *
150
+ * <p>
151
+ * If all the messages are successfully processes, No SQS messages are deleted explicitly but is rather delegated to
152
+ * Lambda execution context for deletion.
153
+ * </p>
154
+ *
155
+ * <p>
156
+ * If you dont want to utility to throw {@link SQSBatchProcessingException} in case of failures but rather suppress
157
+ * it, Refer {@link SqsUtils#batchProcessor(SQSEvent, boolean, Class)}
158
+ * </p>
159
+ *
160
+ * <p>
161
+ * If you want certain exceptions to be treated as permanent failures, i.e. exceptions where the result of retrying will
162
+ * always be a failure and want these can be immediately moved to the dead letter queue associated to the source SQS queue,
163
+ * you can use nonRetryableExceptions parameter to configure such exceptions.
164
+ *
165
+ * Make sure function execution role has sqs:GetQueueAttributes permission on source SQS queue and sqs:SendMessage,
166
+ * sqs:SendMessageBatch permission for configured DLQ.
167
+ *
168
+ * If there is no DLQ configured on source SQS queue and {@link SqsBatch#nonRetryableExceptions()} attribute is set, if
169
+ * nonRetryableExceptions occurs from {@link SqsMessageHandler}, such exceptions will still be treated as temporary
170
+ * exceptions and the message will be moved back to source SQS queue for reprocessing. The same behaviour will occur if
171
+ * for some reason the utility is unable to move the message to the DLQ. An example of this could be because the function
172
+ * is missing the correct permissions.
173
+ * </p>
174
+ * @see <a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html">Amazon SQS dead-letter queues</a>
175
+ * @param event {@link SQSEvent} received by lambda function.
176
+ * @param handler Class implementing {@link SqsMessageHandler} which will be called for each message in event.
177
+ * @param nonRetryableExceptions exception classes that are to be treated as permanent exceptions and to be moved
178
+ * to DLQ.
179
+ * @return List of values returned by {@link SqsMessageHandler#process(SQSMessage)} while processing each message.
180
+ * @throws SQSBatchProcessingException if some messages fail during processing.
181
+ */
134
182
@ SafeVarargs
135
183
public static <R > List <R > batchProcessor (final SQSEvent event ,
136
184
final Class <? extends SqsMessageHandler <R >> handler ,
@@ -173,6 +221,57 @@ public static <R> List<R> batchProcessor(final SQSEvent event,
173
221
return batchProcessor (event , suppressException , handlerInstance );
174
222
}
175
223
224
+ /**
225
+ * This utility method is used to processes each {@link SQSMessage} inside received {@link SQSEvent}
226
+ *
227
+ * <p>
228
+ * Utility will take care of calling {@link SqsMessageHandler#process(SQSMessage)} method for each {@link SQSMessage}
229
+ * in the received {@link SQSEvent}
230
+ * </p>
231
+ *
232
+ * <p>
233
+ * If any exception is thrown from {@link SqsMessageHandler#process(SQSMessage)} during processing of a messages,
234
+ * Utility will take care of deleting all the successful messages from SQS. When one or more single message fails
235
+ * processing due to exception thrown from {@link SqsMessageHandler#process(SQSMessage)}
236
+ * {@link SQSBatchProcessingException} is thrown with all the details of successful and failed messages.
237
+ *
238
+ * </p>
239
+ *
240
+ * <p>
241
+ * If all the messages are successfully processes, No SQS messages are deleted explicitly but is rather delegated to
242
+ * Lambda execution context for deletion.
243
+ * </p>
244
+ *
245
+ * <p>
246
+ * If you dont want to utility to throw {@link SQSBatchProcessingException} in case of failures but rather suppress
247
+ * it, Refer {@link SqsUtils#batchProcessor(SQSEvent, boolean, Class)}
248
+ * </p>
249
+ *
250
+ * <p>
251
+ * If you want certain exceptions to be treated as permanent failures, i.e. exceptions where the result of retrying will
252
+ * always be a failure and want these can be immediately moved to the dead letter queue associated to the source SQS queue,
253
+ * you can use nonRetryableExceptions parameter to configure such exceptions.
254
+ *
255
+ * Make sure function execution role has sqs:GetQueueAttributes permission on source SQS queue and sqs:SendMessage,
256
+ * sqs:SendMessageBatch permission for configured DLQ.
257
+ *
258
+ * If there is no DLQ configured on source SQS queue and {@link SqsBatch#nonRetryableExceptions()} attribute is set, if
259
+ * nonRetryableExceptions occurs from {@link SqsMessageHandler}, such exceptions will still be treated as temporary
260
+ * exceptions and the message will be moved back to source SQS queue for reprocessing. The same behaviour will occur if
261
+ * for some reason the utility is unable to move the message to the DLQ. An example of this could be because the function
262
+ * is missing the correct permissions.
263
+ * </p>
264
+ * @see <a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html">Amazon SQS dead-letter queues</a>
265
+ *
266
+ * @param event {@link SQSEvent} received by lambda function.
267
+ * @param suppressException if this is set to true, No {@link SQSBatchProcessingException} is thrown even on failed
268
+ * messages.
269
+ * @param handler Class implementing {@link SqsMessageHandler} which will be called for each message in event.
270
+ * @param nonRetryableExceptions exception classes that are to be treated as permanent exceptions and to be moved
271
+ * to DLQ.
272
+ * @return List of values returned by {@link SqsMessageHandler#process(SQSMessage)} while processing each message.
273
+ * @throws SQSBatchProcessingException if some messages fail during processing.
274
+ */
176
275
@ SafeVarargs
177
276
public static <R > List <R > batchProcessor (final SQSEvent event ,
178
277
final boolean suppressException ,
@@ -183,6 +282,59 @@ public static <R> List<R> batchProcessor(final SQSEvent event,
183
282
return batchProcessor (event , suppressException , handlerInstance , false , nonRetryableExceptions );
184
283
}
185
284
285
+ /**
286
+ * This utility method is used to processes each {@link SQSMessage} inside received {@link SQSEvent}
287
+ *
288
+ * <p>
289
+ * Utility will take care of calling {@link SqsMessageHandler#process(SQSMessage)} method for each {@link SQSMessage}
290
+ * in the received {@link SQSEvent}
291
+ * </p>
292
+ *
293
+ * <p>
294
+ * If any exception is thrown from {@link SqsMessageHandler#process(SQSMessage)} during processing of a messages,
295
+ * Utility will take care of deleting all the successful messages from SQS. When one or more single message fails
296
+ * processing due to exception thrown from {@link SqsMessageHandler#process(SQSMessage)}
297
+ * {@link SQSBatchProcessingException} is thrown with all the details of successful and failed messages.
298
+ *
299
+ * </p>
300
+ *
301
+ * <p>
302
+ * If all the messages are successfully processes, No SQS messages are deleted explicitly but is rather delegated to
303
+ * Lambda execution context for deletion.
304
+ * </p>
305
+ *
306
+ * <p>
307
+ * If you dont want to utility to throw {@link SQSBatchProcessingException} in case of failures but rather suppress
308
+ * it, Refer {@link SqsUtils#batchProcessor(SQSEvent, boolean, Class)}
309
+ * </p>
310
+ *
311
+ * <p>
312
+ * If you want certain exceptions to be treated as permanent failures, i.e. exceptions where the result of retrying will
313
+ * always be a failure and want these can be immediately moved to the dead letter queue associated to the source SQS queue,
314
+ * you can use nonRetryableExceptions parameter to configure such exceptions.
315
+ *
316
+ * Make sure function execution role has sqs:GetQueueAttributes permission on source SQS queue and sqs:SendMessage,
317
+ * sqs:SendMessageBatch permission for configured DLQ.
318
+ *
319
+ * If you want such messages to be deleted instead, set deleteNonRetryableMessageFromQueue to true.
320
+ *
321
+ * If there is no DLQ configured on source SQS queue and {@link SqsBatch#nonRetryableExceptions()} attribute is set, if
322
+ * nonRetryableExceptions occurs from {@link SqsMessageHandler}, such exceptions will still be treated as temporary
323
+ * exceptions and the message will be moved back to source SQS queue for reprocessing. The same behaviour will occur if
324
+ * for some reason the utility is unable to move the message to the DLQ. An example of this could be because the function
325
+ * is missing the correct permissions.
326
+ * </p>
327
+ * @see <a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html">Amazon SQS dead-letter queues</a>
328
+ * @param event {@link SQSEvent} received by lambda function.
329
+ * @param suppressException if this is set to true, No {@link SQSBatchProcessingException} is thrown even on failed
330
+ * messages.
331
+ * @param handler Class implementing {@link SqsMessageHandler} which will be called for each message in event.
332
+ * @param deleteNonRetryableMessageFromQueue If messages with nonRetryableExceptions are to be deleted from SQS queue.
333
+ * @param nonRetryableExceptions exception classes that are to be treated as permanent exceptions and to be moved
334
+ * to DLQ.
335
+ * @return List of values returned by {@link SqsMessageHandler#process(SQSMessage)} while processing each message.
336
+ * @throws SQSBatchProcessingException if some messages fail during processing.
337
+ */
186
338
@ SafeVarargs
187
339
public static <R > List <R > batchProcessor (final SQSEvent event ,
188
340
final boolean suppressException ,
@@ -227,6 +379,55 @@ public static <R> List<R> batchProcessor(final SQSEvent event,
227
379
return batchProcessor (event , false , handler );
228
380
}
229
381
382
+
383
+ /**
384
+ * This utility method is used to processes each {@link SQSMessage} inside received {@link SQSEvent}
385
+ *
386
+ * <p>
387
+ * Utility will take care of calling {@link SqsMessageHandler#process(SQSMessage)} method for each {@link SQSMessage}
388
+ * in the received {@link SQSEvent}
389
+ * </p>
390
+ *
391
+ * <p>
392
+ * If any exception is thrown from {@link SqsMessageHandler#process(SQSMessage)} during processing of a messages,
393
+ * Utility will take care of deleting all the successful messages from SQS. When one or more single message fails
394
+ * processing due to exception thrown from {@link SqsMessageHandler#process(SQSMessage)}
395
+ * {@link SQSBatchProcessingException} is thrown with all the details of successful and failed messages.
396
+ *
397
+ * </p>
398
+ *
399
+ * <p>
400
+ * If all the messages are successfully processes, No SQS messages are deleted explicitly but is rather delegated to
401
+ * Lambda execution context for deletion.
402
+ * </p>
403
+ *
404
+ * <p>
405
+ * If you dont want to utility to throw {@link SQSBatchProcessingException} in case of failures but rather suppress
406
+ * it, Refer {@link SqsUtils#batchProcessor(SQSEvent, boolean, Class)}
407
+ * </p>
408
+ *
409
+ * <p>
410
+ * If you want certain exceptions to be treated as permanent failures, i.e. exceptions where the result of retrying will
411
+ * always be a failure and want these can be immediately moved to the dead letter queue associated to the source SQS queue,
412
+ * you can use nonRetryableExceptions parameter to configure such exceptions.
413
+ *
414
+ * Make sure function execution role has sqs:GetQueueAttributes permission on source SQS queue and sqs:SendMessage,
415
+ * sqs:SendMessageBatch permission for configured DLQ.
416
+ *
417
+ * If there is no DLQ configured on source SQS queue and {@link SqsBatch#nonRetryableExceptions()} attribute is set, if
418
+ * nonRetryableExceptions occurs from {@link SqsMessageHandler}, such exceptions will still be treated as temporary
419
+ * exceptions and the message will be moved back to source SQS queue for reprocessing.The same behaviour will occur if
420
+ * for some reason the utility is unable to moved the message to the DLQ. An example of this could be because the function
421
+ * is missing the correct permissions.
422
+ * </p>
423
+ * @see <a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html">Amazon SQS dead-letter queues</a>
424
+ * @param event {@link SQSEvent} received by lambda function.
425
+ * @param handler Instance of class implementing {@link SqsMessageHandler} which will be called for each message in event.
426
+ * @param nonRetryableExceptions exception classes that are to be treated as permanent exceptions and to be moved
427
+ * to DLQ.
428
+ * @return List of values returned by {@link SqsMessageHandler#process(SQSMessage)} while processing each message.
429
+ * @throws SQSBatchProcessingException if some messages fail during processing.
430
+ */
230
431
@ SafeVarargs
231
432
public static <R > List <R > batchProcessor (final SQSEvent event ,
232
433
final SqsMessageHandler <R > handler ,
0 commit comments