[rabbitmq-discuss] know when a consumer disconnect from a node

Matthias Radestock matthias at rabbitmq.com
Mon Nov 14 18:59:26 GMT 2011


Kilian,

On 14/11/11 18:39, Kilian C. wrote:
> is it possible to know when a client is disconnected from a rabbitmq node?
>
> This is my env:
>
> 1 rabbitmq node.
> 3 client (publishers/subscribers) severs
>
> when a server crashes/shutdown/disconnects from the rabbitmq server,
> other client server needs to be notified about that.
>
> Is there a way to route/publish a simple (dis)connection message to a
> certain queue/exchange?

There is nothing built-in, but you could implement a custom exchange 
type for this.

The basic idea is that a client, after connecting, creates an exclusive 
queue and binds it to an exchange of the custom exchange type. Due to 
the exclusivity, the queue and hence the binding will get removed when 
the connection is closed. The exchange sees both the bind and unbind 
events and can publish notification messages when it gets them.

See https://github.com/tonyg/presence-exchange for an exchange type that 
does s.t. like that. Warning: this may need some tweaking to get to work 
with recent versions of RabbitMQ.


Regards,

Matthias.


More information about the rabbitmq-discuss mailing list