Spring AMQP Notification/Events on SimpleMessageLi

2019-08-14 02:48发布

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条回答
放荡不羁爱自由
2楼-- · 2019-08-14 03:18

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.

查看更多
登录 后发表回答