Detect and identify consumer loss of connection

417 views
Skip to first unread message

Daniele Ivasse

unread,
Oct 13, 2014, 8:54:16 AM10/13/14
to rabbitm...@googlegroups.com
Hi guys,

I have to identify by IP address consumers that for some reason goes down. So I saw some people implementing a log queue listener to get close of connection messages. It worked for me.

After all, I had to build a cluster for RabbitMQ with mirrored queues and I chose to use HAProxy to handle load balancing between brokers in the cluster. Because of proxy, close of connection messages from log queue inform loss of connection between proxy's ip address instead of consumer one.

I was thinking to get port number of channel that is unique and it can identify each consumer. But the only way to consumer get this information is through message received. I don't think that this information is available on message...isn't it?

If you know any other way to handle with it, please let me know.

Thanks in advance,
Daniele

Michael Klishin

unread,
Oct 13, 2014, 9:04:39 AM10/13/14
to Daniele Ivasse, rabbitm...@googlegroups.com
Channels are not identified by ports but by numbers. Consumers are not identified by channels but by consumer tags. You can retrieve this information via management API (which is a bit harder than it needs to be in 3.3, see list archives if you are not sure how list all consumers).

Note that consumer tags may be server-generated. Those will change if client loses connection and re-connects.

MK

Daniele Ivasse

unread,
Oct 13, 2014, 9:32:56 AM10/13/14
to rabbitm...@googlegroups.com, daniele...@gmail.com
Hi MK,

It's is possible to server gets this consumer tag information and sends to consumer? Because the point is, consumer has a unique identification for server and consumer knows which it is.

Daniele

Michael Klishin

unread,
Oct 13, 2014, 11:04:48 AM10/13/14
to Daniele Ivasse, rabbitm...@googlegroups.com
In response to basic.consume and the with all consumer operations, most notably basic.deliver.

MK

Daniele Ivasse

unread,
Oct 13, 2014, 12:15:20 PM10/13/14
to rabbitm...@googlegroups.com, daniele...@gmail.com
I'm using spring-amqp and spring-rabbit packages. I implemented onMessage method of MessageListener to treat the message.

Can I get this information from message? Because there is no other place that I'm invoking some method to consume message.

Daniele

Gary Russell

unread,
Oct 13, 2014, 12:24:53 PM10/13/14
to Daniele Ivasse, rabbitm...@googlegroups.com
Daniele, 

Spring AMQP doesn't currently expose the consumerTag to the listener.

Feel free to open up an 'Improvement' JIRA issue: https://jira.spring.io/browse/AMQP

Gary Russell
Spring AMQP Lead

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Daniele Ivasse

unread,
Oct 13, 2014, 12:59:48 PM10/13/14
to rabbitm...@googlegroups.com, daniele...@gmail.com
Thank you Gary.

There is another way to detect a consumer loss of connection instead of listening to log queue?

Daniele

Gary Russell

unread,
Oct 13, 2014, 1:14:33 PM10/13/14
to Daniele Ivasse, rabbitm...@googlegroups.com
You could subclass the CachingConnectionFactory and override "shutdownCompleted()"; it is called by the rabbit client when channels are closed for any reason. You can examine the reason and reference properties of the ShutdownSignalException.

The default implementation in the CCF ignores "normal" channel closes and logs other reasons under ERROR.

Laing, Michael

unread,
Oct 13, 2014, 1:18:10 PM10/13/14
to Gary Russell, Daniele Ivasse, rabbitm...@googlegroups.com
You can also listen explicitly, I believe.

See 'rabbitmq_event_echange' here.

ml

Laing, Michael

unread,
Oct 13, 2014, 1:18:43 PM10/13/14
to Gary Russell, Daniele Ivasse, rabbitm...@googlegroups.com
That's 'rabbitmq_event_exchange'
Reply all
Reply to author
Forward
0 new messages