[zeromq-dev] Disable message batching

Martin Sustrik sustrik at 250bpm.com
Tue Apr 20 08:55:15 CEST 2010


Hi Chris,

> I found out that it was a stupidity on my part.  Here is how I got
> into this confusing situation that misled me to speculate batching
> was causing the delay.
> 
> A publisher process outside the firewall needs to publish message via
> a ZMQ_PUB socket.  The subscribers are within the firewall.  So, I
> experiment that with the publisher bind to 5555 and have the
> subscribe connect to the publisher at 5555.
> 
> 1. I started the subscriber first (naturally). 2. Started the
> publisher 3. Subscriber shows that it only received about nine
> hundreds out of a thousand.
> 
> At first, I was just sending the string "Hello" repeatedly 1000
> times.
> 
> After prefixing the string with an integer, I noticed that I was
> missing about the first 100 messages instead of the last 100.  That
> concludes that it wasn't batching that delayed the delivery of the
> message.  It was because of my use of bind on the publisher and
> connect from the subscriber that caused the connection of subscriber
> to the publisher delayed.
> 
> This is a subtle difference that I wasn't aware of. :-)

Ok. Good to know it wasn't a bug.

> Maybe a better way to deal with this kind of problem is to use the
> zmq-forwarder so that both the publisher and the subscriber can both
> "connect" instead of bind.

I don't think there's a real semantic distinction between "connect" and 
"bind". Rather PUB/SUB pattern works as an radio transmission. If you 
are not connected, you won't get the messages sent in the meantime. 
I.e., when you connect, you won't get all the historical messages.

Consider your case. Say the PUB is publishing stock quotes. When SUB 
connects to it it doesn't want all the historical stock quotes (possibly 
many years of them) rather it wants to start listening from that moment on.

Makes sense?
Martin



More information about the zeromq-dev mailing list