Using RabbitMQ (Java client), is there a way to determine if network connection is closed during consume?

前端 未结 2 1761
囚心锁ツ
囚心锁ツ 2021-02-19 15:10

I\'m using RabbitMQ on RHEL 5.3 using the Java client. I have 2 nodes (machines). Node1 is consuming messages from a queue on Node2 using the Java helper class QueueingConsume

2条回答
  •  暖寄归人
    2021-02-19 15:28

    Regarding the isOpen method, that is well described in the docs: http://www.rabbitmq.com/api-guide.html#shutdown-atomicity

    Regarding the shutting down: with shutting down node1 or 2 you mean the application right, not the RabbitMQ server itself? Why would you want to know on any application if another application disconnects from the message broker? That's not the point of messaging.

    The only thing you can do, is send messages with a 'mandatory' parameter. That tells the RabbitMQ server you expect at least 1 listener for the message you've sent (whether that be a direct queue or some queue in a topic/fanout exchange). If the message then can not be delivered to any queue, the message will return to your channel and forwarded to given ReturnListener.

提交回复
热议问题