简体   繁体   English

Spring Rabbit Listener关闭处理程序或返回没有重新传递标志的消息

[英]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.在任何情况下,将消息重新发送到队列都会改变消息顺序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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