Notify ActiveMQ producer if consumer on the destination is down

百般思念 提交于 2019-12-12 19:09:02

问题


I am using ActiveMQ messaging broker and I have a requirement where the producer application would want to know if the consumer application consuming on the particular destination is up or not?

How can I achieve this?

Thanks!


回答1:


You should checkout Advisory messages. It's a topic you can subscribe to if you want updates on such events.

Specifically the topic: ActiveMQ.Advisory.NoConsumer.Queue should be of interest. You need to enable it broker side though using the destination policy property: sendAdvisoryIfNoConsumers.




回答2:


You can do that by using java code as follows:

Destination class has a method getConsumers() which will return List of Subscriptions to that destination,and it will in turn give you consumer information, by this you can check whether your required consumer is active or not.

Good luck!



来源:https://stackoverflow.com/questions/28340546/notify-activemq-producer-if-consumer-on-the-destination-is-down

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!