Ricardo Piccoli
Ricardo Piccoli

Reputation: 491

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?

Upvotes: 4

Views: 8647

Answers (2)

Niraj Sonawane
Niraj Sonawane

Reputation: 11055

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

Upvotes: 5

Ricardo Piccoli
Ricardo Piccoli

Reputation: 491

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) { ... }

Upvotes: 10

Related Questions