[zeromq-dev] Changing subscriber's topic
Eric Bell
eric at ericjbell.com
Fri Jul 30 05:50:58 CEST 2010
What is the behavior when subscriber in a publish-subcribe pattern
changes the message topic (aka message type) it is subscribed to?
I ran a test where I changed the message topic and then repeatedly read
all messages from the socket until an exception was thrown. The messages
that were read were from both the previous topic and the new topic.
Here is a snippet of my python code:
if topic=='b':
topic = 'g'
else:
topic = 'b'
socket.setsockopt(zmq.SUBSCRIBE, topic)
status = ''
while True:
try:
event = socket.recv(zmq.NOBLOCK)
status = event + '\n' + status
except:
if status == '':
status = 'no message received'
break
When the loop terminates, the variable "status" contains messages that
start with both "b" and "g". This doesn't seem like desirable behavior,
but what isn't clear to me is whether the queue should return all
messages that have been queued of the new topic since the socket was
created, or only new messages that arrive once the topic has been
changed ... but not some messages of one topic and some messages of
another topic.
--eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20100729/bcfe8f6e/attachment.htm>
More information about the zeromq-dev
mailing list