[zeromq-dev] Order by which PUB/SUB requests are sent/processed
jbaclor at ezuce.com
Tue Jan 24 11:27:00 CET 2012
We have an application the uses PUP/SUB sockets. One requirement that
ZeroMQ gracefully meets is being able to reliably send events to all
subscribers. However, there is a requirement in our application that
relies on which client gets the event first. We were under the
assumption that ZeroMQ randomizes the sending of events to the mutiple
subscribers so that no one subscriber always gets a first hit.
Unfortunately, this seems to be not the case. ZeroMq seems to follow a
specific fix order. We have created 3 clients each incrementing a
counter if it was the first one to get the publication. Take the output
below (each iteration is 1500 events):
Client 1 processed 1496 events.
Client 2 processed 0 events.
Client 3 processed 4 events.
Client 1 processed 2309 events.
Client 2 processed 647 events.
Client 3 processed 44 events.
Client 1 processed 2992 events.
Client 2 processed 1385 events.
Client 3 processed 123 events.
Client 1 processed 3623 events.
Client 2 processed 1951 events.
Client 3 processed 426 events.
Client 1 processed 4207 events.
Client 2 processed 2697 events.
Client 3 processed 723 events.
TestDriver::TestMultiplePop ... Ok
Clearly, the order is predictable. client 1 gets the highest hit and
client 3 gets the lowest hit. Is there a way so that we can spread this
evenly across the subscribers?
More information about the zeromq-dev