@@ -131,6 +131,50 @@ 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 which are not worth retrying and
162
+ * want such message should be moved to configured dead letter queue of the source SQS queue, you can use
163
+ * {@link SqsBatch#nonRetryableExceptions()} to configure such exceptions.
164
+ *
165
+ * If there is no DLQ configured on source SQS queue and {@link SqsBatch#nonRetryableExceptions()} attribute is set, if
166
+ * nonRetryableExceptions occurs from {@link SqsMessageHandler}, such exceptions will still be treated as temporary
167
+ * exceptions and the message will be move back to source SQS queue for reprocessing. Same behaviour occurs if for some
168
+ * reason utility is unable to move message to the DLQ. This can occur because of missing permissions.
169
+ * </p>
170
+ *
171
+ * @param event {@link SQSEvent} received by lambda function.
172
+ * @param handler Class implementing {@link SqsMessageHandler} which will be called for each message in event.
173
+ * @param nonRetryableExceptions exception classes that are to be treated as permanent exceptions and to be moved
174
+ * to DLQ.
175
+ * @return List of values returned by {@link SqsMessageHandler#process(SQSMessage)} while processing each message.
176
+ * @throws SQSBatchProcessingException if some messages fail during processing.
177
+ */
134
178
@ SafeVarargs
135
179
public static <R > List <R > batchProcessor (final SQSEvent event ,
136
180
final Class <? extends SqsMessageHandler <R >> handler ,
@@ -173,6 +217,52 @@ public static <R> List<R> batchProcessor(final SQSEvent event,
173
217
return batchProcessor (event , suppressException , handlerInstance );
174
218
}
175
219
220
+ /**
221
+ * This utility method is used to processes each {@link SQSMessage} inside received {@link SQSEvent}
222
+ *
223
+ * <p>
224
+ * Utility will take care of calling {@link SqsMessageHandler#process(SQSMessage)} method for each {@link SQSMessage}
225
+ * in the received {@link SQSEvent}
226
+ * </p>
227
+ *
228
+ * <p>
229
+ * If any exception is thrown from {@link SqsMessageHandler#process(SQSMessage)} during processing of a messages,
230
+ * Utility will take care of deleting all the successful messages from SQS. When one or more single message fails
231
+ * processing due to exception thrown from {@link SqsMessageHandler#process(SQSMessage)}
232
+ * {@link SQSBatchProcessingException} is thrown with all the details of successful and failed messages.
233
+ *
234
+ * </p>
235
+ *
236
+ * <p>
237
+ * If all the messages are successfully processes, No SQS messages are deleted explicitly but is rather delegated to
238
+ * Lambda execution context for deletion.
239
+ * </p>
240
+ *
241
+ * <p>
242
+ * If you dont want to utility to throw {@link SQSBatchProcessingException} in case of failures but rather suppress
243
+ * it, Refer {@link SqsUtils#batchProcessor(SQSEvent, boolean, Class)}
244
+ * </p>
245
+ *
246
+ * <p>
247
+ * If you want certain exceptions to be treated as permanent failures, i.e. exceptions which are not worth retrying and
248
+ * want such message should be moved to configured dead letter queue of the source SQS queue, you can use
249
+ * {@link SqsBatch#nonRetryableExceptions()} to configure such exceptions.
250
+ *
251
+ * If there is no DLQ configured on source SQS queue and {@link SqsBatch#nonRetryableExceptions()} attribute is set, if
252
+ * nonRetryableExceptions occurs from {@link SqsMessageHandler}, such exceptions will still be treated as temporary
253
+ * exceptions and the message will be move back to source SQS queue for reprocessing. Same behaviour occurs if for some
254
+ * reason utility is unable to move message to the DLQ. This can occur because of missing permissions.
255
+ * </p>
256
+ *
257
+ * @param event {@link SQSEvent} received by lambda function.
258
+ * @param suppressException if this is set to true, No {@link SQSBatchProcessingException} is thrown even on failed
259
+ * messages.
260
+ * @param handler Class implementing {@link SqsMessageHandler} which will be called for each message in event.
261
+ * @param nonRetryableExceptions exception classes that are to be treated as permanent exceptions and to be moved
262
+ * to DLQ.
263
+ * @return List of values returned by {@link SqsMessageHandler#process(SQSMessage)} while processing each message.
264
+ * @throws SQSBatchProcessingException if some messages fail during processing.
265
+ */
176
266
@ SafeVarargs
177
267
public static <R > List <R > batchProcessor (final SQSEvent event ,
178
268
final boolean suppressException ,
@@ -183,6 +273,54 @@ public static <R> List<R> batchProcessor(final SQSEvent event,
183
273
return batchProcessor (event , suppressException , handlerInstance , false , nonRetryableExceptions );
184
274
}
185
275
276
+ /**
277
+ * This utility method is used to processes each {@link SQSMessage} inside received {@link SQSEvent}
278
+ *
279
+ * <p>
280
+ * Utility will take care of calling {@link SqsMessageHandler#process(SQSMessage)} method for each {@link SQSMessage}
281
+ * in the received {@link SQSEvent}
282
+ * </p>
283
+ *
284
+ * <p>
285
+ * If any exception is thrown from {@link SqsMessageHandler#process(SQSMessage)} during processing of a messages,
286
+ * Utility will take care of deleting all the successful messages from SQS. When one or more single message fails
287
+ * processing due to exception thrown from {@link SqsMessageHandler#process(SQSMessage)}
288
+ * {@link SQSBatchProcessingException} is thrown with all the details of successful and failed messages.
289
+ *
290
+ * </p>
291
+ *
292
+ * <p>
293
+ * If all the messages are successfully processes, No SQS messages are deleted explicitly but is rather delegated to
294
+ * Lambda execution context for deletion.
295
+ * </p>
296
+ *
297
+ * <p>
298
+ * If you dont want to utility to throw {@link SQSBatchProcessingException} in case of failures but rather suppress
299
+ * it, Refer {@link SqsUtils#batchProcessor(SQSEvent, boolean, Class)}
300
+ * </p>
301
+ *
302
+ * <p>
303
+ * If you want certain exceptions to be treated as permanent failures, i.e. exceptions which are not worth retrying and
304
+ * want such message should be moved to configured dead letter queue of the source SQS queue, you can use
305
+ * {@link SqsBatch#nonRetryableExceptions()} to configure such exceptions. If you want such messages to be deleted
306
+ * instead, set deleteNonRetryableMessageFromQueue to true.
307
+ *
308
+ * If there is no DLQ configured on source SQS queue and {@link SqsBatch#nonRetryableExceptions()} attribute is set, if
309
+ * nonRetryableExceptions occurs from {@link SqsMessageHandler}, such exceptions will still be treated as temporary
310
+ * exceptions and the message will be move back to source SQS queue for reprocessing. Same behaviour occurs if for some
311
+ * reason utility is unable to move message to the DLQ. This can occur because of missing permissions.
312
+ * </p>
313
+ *
314
+ * @param event {@link SQSEvent} received by lambda function.
315
+ * @param suppressException if this is set to true, No {@link SQSBatchProcessingException} is thrown even on failed
316
+ * messages.
317
+ * @param handler Class implementing {@link SqsMessageHandler} which will be called for each message in event.
318
+ * @param deleteNonRetryableMessageFromQueue If messages with nonRetryableExceptions are to be deleted from SQS queue.
319
+ * @param nonRetryableExceptions exception classes that are to be treated as permanent exceptions and to be moved
320
+ * to DLQ.
321
+ * @return List of values returned by {@link SqsMessageHandler#process(SQSMessage)} while processing each message.
322
+ * @throws SQSBatchProcessingException if some messages fail during processing.
323
+ */
186
324
@ SafeVarargs
187
325
public static <R > List <R > batchProcessor (final SQSEvent event ,
188
326
final boolean suppressException ,
@@ -227,6 +365,51 @@ public static <R> List<R> batchProcessor(final SQSEvent event,
227
365
return batchProcessor (event , false , handler );
228
366
}
229
367
368
+
369
+ /**
370
+ * This utility method is used to processes each {@link SQSMessage} inside received {@link SQSEvent}
371
+ *
372
+ * <p>
373
+ * Utility will take care of calling {@link SqsMessageHandler#process(SQSMessage)} method for each {@link SQSMessage}
374
+ * in the received {@link SQSEvent}
375
+ * </p>
376
+ *
377
+ * <p>
378
+ * If any exception is thrown from {@link SqsMessageHandler#process(SQSMessage)} during processing of a messages,
379
+ * Utility will take care of deleting all the successful messages from SQS. When one or more single message fails
380
+ * processing due to exception thrown from {@link SqsMessageHandler#process(SQSMessage)}
381
+ * {@link SQSBatchProcessingException} is thrown with all the details of successful and failed messages.
382
+ *
383
+ * </p>
384
+ *
385
+ * <p>
386
+ * If all the messages are successfully processes, No SQS messages are deleted explicitly but is rather delegated to
387
+ * Lambda execution context for deletion.
388
+ * </p>
389
+ *
390
+ * <p>
391
+ * If you dont want to utility to throw {@link SQSBatchProcessingException} in case of failures but rather suppress
392
+ * it, Refer {@link SqsUtils#batchProcessor(SQSEvent, boolean, Class)}
393
+ * </p>
394
+ *
395
+ * <p>
396
+ * If you want certain exceptions to be treated as permanent failures, i.e. exceptions which are not worth retrying and
397
+ * want such message should be moved to configured dead letter queue of the source SQS queue, you can use
398
+ * {@link SqsBatch#nonRetryableExceptions()} to configure such exceptions.
399
+ *
400
+ * If there is no DLQ configured on source SQS queue and {@link SqsBatch#nonRetryableExceptions()} attribute is set, if
401
+ * nonRetryableExceptions occurs from {@link SqsMessageHandler}, such exceptions will still be treated as temporary
402
+ * exceptions and the message will be move back to source SQS queue for reprocessing. Same behaviour occurs if for some
403
+ * reason utility is unable to move message to the DLQ. This can occur because of missing permissions.
404
+ * </p>
405
+ *
406
+ * @param event {@link SQSEvent} received by lambda function.
407
+ * @param handler Instance of class implementing {@link SqsMessageHandler} which will be called for each message in event.
408
+ * @param nonRetryableExceptions exception classes that are to be treated as permanent exceptions and to be moved
409
+ * to DLQ.
410
+ * @return List of values returned by {@link SqsMessageHandler#process(SQSMessage)} while processing each message.
411
+ * @throws SQSBatchProcessingException if some messages fail during processing.
412
+ */
230
413
@ SafeVarargs
231
414
public static <R > List <R > batchProcessor (final SQSEvent event ,
232
415
final SqsMessageHandler <R > handler ,
0 commit comments