[zeromq-dev] [otish] "Why ZeroMQ"

Oliver Smith oliver at kfs.org
Tue Jul 27 08:48:21 CEST 2010


On 7/26/2010 8:30 PM, Matt Weinstein wrote:
> I've been using ZMQ_STREAM_SOURCE and ZMQ_STREAM_SINK.
>
> There's still that "from which perspective?" problem.
>
> How about ZMQ_IWANTBYTES and ZMQ_IGOTBYTES :-)
>
>    
Ha - same problem - they both seem to be anchored around the viewpoint 
of one end of the connection (the ZMQ_DOWNSTREAM endpoint doesn't want 
bytes, it wants to get rid of them to the IGOTBYTES end ;)

That's where PUB and SUB work so well... Each name uniquely describes 
it's end of the connection without relation to the other. PUB = I want 
to publish stuff. SUB = I want to subscribe to stuff. The two verbs are 
also delivery-oriented and so resolve the potential perspective issue. 
You subscribe to a publisher, a publisher issues you your subscription.

REQ/REP are a little more fragile because both end points do two things, 
and there is this little gray area in that first recv() on the server 
end where you are receiving a REQuest in order to begin your reply. 
That's a bit long for a mental tokenization.

That's why for some, ZMQ_UPSTREAM would make more sense for the sender 
side - you insert packets upstream and they arrive downstream; you put 
your boat on the river at the upstream point and unload it at the 
downstream point. !!! But that's only for some !!! (I just happen to be 
one ;-p)

I realize this may seem totally trivial semantics, "A rose is a rose", 
just don't underestimate the power of imemdiately-grokable names.

I've gotten a ton of people asking me in email now about the UP/DOWN 
stream thing, after viewing the video. Getting them to make the paradigm 
shift to message passing (especially the old C programmers) is hard 
enough, telling them they need to look at the naming the right way 
doesn't help :)

Finding some names that none of us would be ambiguous about ... would go 
a huge way to keeping people reading when they are investigating ZeroMQ. 
By the end of reading the following you shouldn't need to ask "What does 
...?"

     C = library.call(0001)
     S = C.member(0x07)
     R = S.operation(fooManChu)

(0x07 is the #define for ZMQ_UPSTREAM, so if 'operation' is not 'bind', 
that code is broke ;)

Message Generator:
     C = zmq_init(1)
     PipelineOutgoing = C.socket( ZMQ_PIPELINE_OUTGOING )    // 
ZMQ_PLINE_SEND?
     PipelineOutgoing.bind(fooManChu)
     PipelineOutgoing.send(msg)

Message Recipient:
     C = zmq_init(1)
     PipelineIncoming = C.socket( ZMQ_PIPELINE_INCOMING ) // ZMQ_PLINE_RECV?
     PipelineIncoming.connect(fooManChu)
     PipelineIncoming.recv(&msg)

Right now I'm stumped for one for REQ/REP :)

- Ol




More information about the zeromq-dev mailing list