[zeromq-dev] PUB doesn't discard msg when no SUB
Li, Jia
jia.li at credit-suisse.com
Thu May 26 18:57:29 CEST 2011
Hi,
I have multiple PUB sockets and single SUB socket. The PUBs perform
connect() and the SUB performs bind().
The problem I see is that if the SUB starts after the PUBs, it still
receive all the messages sent before. This seems to contradict to what
the documentation said.
However, if I have only one PUB and one SUB, and I reverse the
connect/bind by having PUB bind() and SUB connect(), I get the
documented behavior in which SUB doesn't receive historical messages.
Here are the code:
SUB
-------
import zmq
context = zmq.Context()
sub = context.socket(zmq.SUB)
sub.setsockopt(zmq.SUBSCRIBE, "")
sub.bind("tcp://127.0.0.1:27888")
while(1):
msg = sub.recv()
print msg
PUB
-------
import zmq, time
from datetime import datetime
context = zmq.Context()
pub = context.socket(zmq.PUB)
pub.connect("tcp://127.0.0.1:27888")
while(1):
msg = datetime.now().strftime('%H:%M:%S.%f')
print msg
pub.send(msg)
time.sleep(1)
Regards,
Jia
===============================================================================
Please access the attached hyperlink for an important electronic communications disclaimer:
http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
===============================================================================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20110526/b1dd5e28/attachment.htm>
More information about the zeromq-dev
mailing list