[zeromq-dev] Using ØMQ just as in-memory queue

Martin Sustrik sustrik at 250bpm.com
Mon Sep 12 18:53:43 CEST 2011


Hi Anatoly,

>     In case we process these "different typed" messages in a single
> thread ( void *context = zmq_init (*1*); ), but still using a ZMQ.PUB /
> ZMQ.SUB pattern, would we be able to create multiple subscribers from
> this same "ZMQ.Socket":

Yes.

>         1.  If yes, would "subscriberA.recv( 0 )" block the
> "subscriberB.recv( 0 )"?

This way, right;

     A.recv ();
     B.recv ();

Obviously blocking call will block if there's no message available and 
the second line won't be executed.

You can deal with this be either using zmq_poll() or simply using a 
single SUB socket and subscribing to both topics.

>         2.  In case a PUB/SUB is not a good match here ( which is a
> shame since we would need to parse message types, and do the dispatch
> manually ), what would the right pattern be?

PUB/SUB is OK.

However, if you need messages to be perfectly ordered you have to pass 
them through a single socket which means you have to check the message 
type yourself.

Martin



More information about the zeromq-dev mailing list