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

Anatoly tolitius at gmail.com
Mon Sep 12 19:52:25 CEST 2011


Hi Martin,

Thanks for clearing it up.

Just want to make sure I fully understand what you suggested => 

"If I need to consume different typed messages in order they were sent. In case I use PUB/SUB; to ensure the perfect order, I should use a single socket, and have a single subscriber that is subscribed to everything ( "zmq_setsockopt (subscriber, ZMQ_SUBSCRIBE, "", ...);" ) [ and then I should parse out a message type manually => no point to create pubsub envelopes, etc.. ]?"

Thank you,
/Anatoly


-- 
Anatoly
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Monday, September 12, 2011 at 12:53 PM, Martin Sustrik wrote:

> 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20110912/bd26d750/attachment.htm>


More information about the zeromq-dev mailing list