views:

390

answers:

1

I'm trying to replace a small homegrown messaging system, and are playing around a bit with zmq . I'll be needing to detect slow readers, and boot/disconnect them - slow readers pretty much meaning a particular consumer whos queue size is above a certain threshold.

So far it seems zmq blocks every consumer if one of them is a bit slow (fair enough) - but I can't find any way to detect a potential slow consumer. Anyone have any experience with wether and how this is possible with zmq - or have any other broker-less messaging system to recccommend ?

A: 

As of zeromq-2.0.7, you can set the ZMQ_HWM option on a ZMQ_PUB socket to control the maximum number of messages that can be queued for a subscriber. Once the high-water mark has been reached, all further messages destined for that subscriber will be dropped until the queue size drops back below the high-water mark. This limits the amount of memory dedicated to what you call a slow reader.

However, because the ZeroMQ library exposes sockets, not clients, there is no way for you to identify and forcibly disconnect unwanted clients without modifying the library itself.

Jeremy W. Sherman