@@ -242,6 +242,36 @@ void shouldBatchProcessAndMoveNonRetryableExceptionToDlq() {
242
242
verify (sqsClient ).sendMessageBatch (any (Consumer .class ));
243
243
}
244
244
245
+ @ Test
246
+ void shouldBatchProcessAndDeleteNonRetryableException () {
247
+ String failedId = "2e1424d4-f796-459a-8184-9c92662be6da" ;
248
+ HashMap <QueueAttributeName , String > attributes = new HashMap <>();
249
+
250
+ attributes .put (QueueAttributeName .REDRIVE_POLICY , "{\n " +
251
+ " \" deadLetterTargetArn\" : \" arn:aws:sqs:us-east-2:123456789012:retry-queue\" ,\n " +
252
+ " \" maxReceiveCount\" : 2\n " +
253
+ "}" );
254
+
255
+ when (sqsClient .getQueueAttributes (any (GetQueueAttributesRequest .class ))).thenReturn (GetQueueAttributesResponse .builder ()
256
+ .attributes (attributes )
257
+ .build ());
258
+
259
+ List <String > batchProcessor = batchProcessor (event , false , (message ) -> {
260
+ if (failedId .equals (message .getMessageId ())) {
261
+ throw new IllegalStateException ("Failed processing" );
262
+ }
263
+
264
+ interactionClient .listQueues ();
265
+ return "Success" ;
266
+ }, true , IllegalStateException .class , IllegalArgumentException .class );
267
+
268
+ Assertions .assertThat (batchProcessor )
269
+ .hasSize (1 );
270
+
271
+ verify (sqsClient , times (0 )).sendMessageBatch (any (Consumer .class ));
272
+ verify (sqsClient ).deleteMessageBatch (any (DeleteMessageBatchRequest .class ));
273
+ }
274
+
245
275
public class FailureSampleInnerSqsHandler implements SqsMessageHandler <String > {
246
276
@ Override
247
277
public String process (SQSEvent .SQSMessage message ) {
0 commit comments