[zeromq-dev] PUB doesn't discard msg when no SUB

Brian Dorsey briandorsey at gmail.com
Mon May 30 09:15:33 CEST 2011

On Thu, May 26, 2011 at 12:39 PM, Martin Sustrik <sustrik at 250bpm.com> wrote:
> On 05/26/2011 09:27 PM, Li, Jia wrote:
>> Putting timestamp can be a work-around, but not efficient, as the SUB
>> has to compare current time against message time for every message.
>> It'd be nice to have this behavior either explained in the Guide or
>> brought consistent with the intended usage.
> Try setting HWM to 1 on the PUB side. That should drop any outstanding
> messages except for one.

I'm doing something similar (many PUBs one SUB which binds). I'm using
it to collect the status of long-running services. Some of the
services live on the other side of poor network connections. I only
care about the most recent status, and if the collector isn't
reachable I don't want to affect the services.

It's a perfect fit, except for the HWM. I ended up setting it to 1,
and that works OK for me since I update status often - the first one
after a service becomes visible again will be very old, but it will
soon be replaced. For my use case, being able to set HWM so that no
outstanding messages are saved would be perfect. When the publisher
can't connect, I get no status, and when it comes back, I immediately
get the most recent status.

Take care,

More information about the zeromq-dev mailing list