Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Cloud AWS SQS Deletion Policy

We have a SQS listener, such as:

@MessageMapping("queueName")
void listen(String message) { ... }

This queue has redrive policy configured with an associated dead letter queue.

The problem is that the default Spring Cloud AWS implementation is deleting the message when polling it and wiring internally 3 retries for processing it, and failing afterwards.

I can see there is a SqsMessageDeletionPolicy enum with ALWAYS and ON_SUCCESS values, among others. I can't find in any documentation how can I change the QueueAttributes for that queue in order to change this behaviour.

Does anyone knows?

like image 803
Ricardo Piccoli Avatar asked Oct 15 '25 23:10

Ricardo Piccoli


2 Answers

Seems like the solution is basically to use the SQS specific annotation instead of the generic one:

@SqsListener(value = "queueName", deletionPolicy = SqsMessageDeletionPolicy.ON_SUCCESS)
void listen(String message) { ... }
like image 184
Ricardo Piccoli Avatar answered Oct 17 '25 12:10

Ricardo Piccoli


Accepted answer shows how to configure Deletion policy for single Queue,

If you want to set a Global deletion policy which will be used by all @SqsListener can be set by using a property: cloud.aws.sqs.handler.default-deletion-policy=ON_SUCCESS

like image 36
Niraj Sonawane Avatar answered Oct 17 '25 14:10

Niraj Sonawane



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!