Question

If the rabbitmq client connect to the server and not send the message for a long time, is it possible to monitor and close their connection by programming? How to get these related information?

No correct solution

OTHER TIPS

Two things will make sure this does not happen:

  • Your packet can't get through TCP in due time. This will be handled by the kernel and you will get a connection close error. If you configure your client correctly, it will tell you that this is the case and you can then handle the problem. The easiest way is to monitor the Pid of the channel you have and then react if it dies, but there are perhaps other methods (I can't remember the details).

  • RabbitMQ keepalive packets does not arrive in time. This will forcefully terminate the connection. The same as above applies. Having a monitor will help. A "Channel" in the rabbitmq Erlang client is a Pid so it can be monitored (erlang:monitor(process, Pid)).

  • You manage to send the message, but there is no queue to which the message gets delivered. This can be handled by subscribing to channel events. You will get a 312 - No Route message back from RabbitMQ.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top