[zeromq-dev] New bug in pub/sub since multipart

Martin Sustrik sustrik at 250bpm.com
Sat May 15 08:00:18 CEST 2010

Brian Granger wrote:
> Hi,
> I am in the process of making sure the Python zeromq test suite passes
> with the new multipart message stuff.  We have a simple pub/sub tests
> that is failing, that used to pass.  Here is an outline of the
> session:
> Process #1                                              Process #2
> import zmq                                              import zmq
> c = zmq.Context()                                    c = zmq.Context()
> s = c.socket(zmq.SUB)                            s = c.socket(zmq.PUB)
> s.connect('tcp://')                s.bind('tcp://')
> s.setsockopt(zmq.SUBSCRIBE,'')
> # Wait for a while to allow connection...
>                                                               s.send('foo')
> s.recv(zmq.NOBLOCK) # Nothing!
>                                                               s.send('bar')
> s.recv(zmq.NOBLOCK) # 'bar'
>                                                               s.send('bam')
> s.recv(zmq.NOBLOCK) # 'bam'
> Each process was typed interactively, so the time scales between
> everything are long (seconds) - plenty enough time for zeromq to
> connect, send/recv.
> I am wondering if the underlying problem is the following.
> Previously, the topic and message was sent in a single send
> ("topicmessage").  Now the idea is that you can send the topic and
> message are parts:
> s.send_multipart(['topic','message'])  # the python version.
> But, what happens with pub/sub sockets now if the message only has 1
> part (like my example).  In other words, the topic and message are
> sent as 1 part?  What is the desired behavior?  Should this still
> work?  Do we always require a min of 2 parts for a pub/sub socket?

Yes, it should work. The functionality haven't changed. The only thing 
added is "When multi-part message is sent from PUB to SUB, matching is 
done only on the first part of the message."

One additional question: Is there a sleep after the bind?


More information about the zeromq-dev mailing list