[zeromq-dev] Lazy subscriber, only receive last message

Mathieu Westphal mathieu.westphal at gmail.com
Wed Oct 15 18:32:20 CEST 2014


On Wed, Oct 15, 2014 at 01:24:37PM +0200, Dorvin wrote:
> W dniu 2014-10-15 12:20, Mathieu Westphal pisze:
> 
> > server will send 10 message when the client as the time only to receive and use one.
> > The thing is, the client doesn't care at all about losing message, but it cares about getting the last sent message.
> If you send only single part messages then you might use ZMQ_CONFLATE.
> >
> > I've tried to use high water mark for that, but it does not seem to work at all.
> > I've also seen this post from 2011, http://lists.zeromq.org/pipermail/zeromq-dev/2011-May/011081.html,
> > wich propose the use of dedicated reader thread on the client, but the downside of this solution is the message are indeed transferred on the network while they could have been dropped !
> This is no longer necessary as pub/sub filtering is currently performed 
> on publisher's side.
> >
> > My solution is to connect/deconnect the client each time i want to receive a message, but the connect method take some milliseconds, so it is not good also.
> >
> This is lengthy operation. If CONFLATE is not an option you may consider 
> doing subscribe/unsubscribe which should be significantly faster. Other 
> option would include changing from pub/sub to f.e. req/rep. This way 
> requestor (previously subscriber) could ask for last message.
FYY this solution does not work at high speed, you actually get a lot a message between the 
SUBSCRIBE 
receive
UNSUBSCRIBE

setting werver SNDHWM to 1 do the trick.

Mathieu
> 
> 
> Cheers,
> Jarek
> 
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev



More information about the zeromq-dev mailing list