问题
I have a scenario where I am consuming messages from queues using SimpleMessageListenerContainer
. When any of these subscribed queues got deleted, I would like to get notification or events.
SimpleMessageListenerContainer simpleMessageListenerContainer
= new SimpleMessageListenerContainer(cachingConnectionFactory);
simpleMessageListenerContainer.setQueueNames(
"testQueue1","testQueue2","testQueue3");
simpleMessageListenerContainer.start();
回答1:
There is currently no event published when a consumer is cancelled due to a queue being deleted, aside from logging a WARN log.
Feel free to open an Improvement JIRA Issue and we'll see if we can get something into the upcoming 1.5 release.
In the meantime, you could possibly hook into your logging subsystem (e.g. configure a custom appender), or even one of the AMQP appenders provided by the framework for log4j and logback and have a consumer on the logger queue look for the consumer cancelled log.
来源:https://stackoverflow.com/questions/30988483/spring-amqp-notification-events-on-simplemessagelistenercontainer-when-queue-ge