简体   繁体   中英

Spring Rabbit Listener shutdown handler or return message without redelivered flag

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 (eg 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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM