-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(batch-processing): Support for moving non retryable msg to DLQ
- Loading branch information
Pankaj Agrawal
committed
Aug 12, 2021
1 parent
7ec6fd3
commit 242736b
Showing
6 changed files
with
232 additions
and
29 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
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
33 changes: 33 additions & 0 deletions
33
...tware/amazon/lambda/powertools/sqs/handlers/SqsMessageHandlerWithNonRetryableHandler.java
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,33 @@ | ||
package software.amazon.lambda.powertools.sqs.handlers; | ||
|
||
import com.amazonaws.services.lambda.runtime.Context; | ||
import com.amazonaws.services.lambda.runtime.RequestHandler; | ||
import com.amazonaws.services.lambda.runtime.events.SQSEvent; | ||
import software.amazon.lambda.powertools.sqs.SqsBatch; | ||
import software.amazon.lambda.powertools.sqs.SqsMessageHandler; | ||
|
||
import static com.amazonaws.services.lambda.runtime.events.SQSEvent.SQSMessage; | ||
import static software.amazon.lambda.powertools.sqs.internal.SqsMessageBatchProcessorAspectTest.mockedRandom; | ||
|
||
public class SqsMessageHandlerWithNonRetryableHandler implements RequestHandler<SQSEvent, String> { | ||
|
||
@Override | ||
@SqsBatch(value = InnerMessageHandler.class, nonRetryableExceptions = {IllegalStateException.class, IllegalArgumentException.class}) | ||
public String handleRequest(final SQSEvent sqsEvent, | ||
final Context context) { | ||
return "Success"; | ||
} | ||
|
||
private class InnerMessageHandler implements SqsMessageHandler<Object> { | ||
|
||
@Override | ||
public String process(SQSMessage message) { | ||
if(message.getMessageId().isEmpty()) { | ||
throw new IllegalArgumentException("Invalid message and was moved to DLQ"); | ||
} | ||
|
||
mockedRandom.nextInt(); | ||
return "Success"; | ||
} | ||
} | ||
} |