Reputation: 3844
I have an unusual scenario in which I don't want a message to be sent back to the queue with the redelivered flag if my application has been shutdown gracefully (e.g. autoscaling) during processing of the message. I want the flag to be set only if the application crashes. I have a functionality in the code that treats redelivered messages differently and redelivered messages due to a graceful shutdown shouldn't be considered. I'm looking for some kind of a shutdown handler from which I can send a copy of the message to the same queue and discard the original message, this way I could avoid setting the redelivered flag.
Is there a way to return messages back to the queue without setting the redelivered flag if my application has been shutdown gracefully?
Upvotes: 0
Views: 339
Reputation: 174729
Is there a way to return messages back to the queue without setting the redelivered flag if my application has been shutdown gracefully?
No; once it's delivered and rejected (and requeued) for any reason, the redelivered flag will be set.
There are no hooks in the framework to do what you want; re-sending the message to the queue would change the message order in any case.
Upvotes: 1