[zeromq-dev] Devices, and pipeline again

Jon Dyte jon at totient.co.uk
Thu Jul 29 22:33:34 CEST 2010


Pieter Hintjens wrote:
> Hi All,
>
> I'm writing a new generic zmq_device that will replace zmq_queue,
> zmq_forwarder and zmq_streamer.
>
>   
Pieter

There was also the a generic zmqd I wrote which replaced the standalone 
zmq_forwarder, zmq_streamer, zmq_queue binaries.

This got purged from the 2.0.7 release but is in Martin S tree here:

http://github.com/sustrik/zeromq2/blob/master/zmqd/zmqd.cpp


This will parse a config file and allow multiple devices in the same 
binary each in it's own thread

Some of the code may be of use.

The other requirement from the config file is that the socket options be 
settable.

Jon



> The code is here: http://dpaste.de/4DcP/
>
> The zmq_device works a lot like the zmq::device method.  There is
> documentation at the start of the source code, which I'll expand to
> become a man page when this is stable.
>
> Anyone who is already using devices: your feedback would be useful.
> Especially, do you use multiple in/out sockets (I've renamed that to
> 'frontend' and 'backend' here)?  And do you connect outwards from your
> device, using it as a proxy, or do you connect into it, using it as a
> mini-broker?
>
> Second thing, those pipeline sockets again.  Here is the core of the
> generic device, acting as broker (such short sweet code, thank you
> 0MQ!):
>
>         int device = parse_device (argv [1]);
>         switch (device) {
>             case ZMQ_QUEUE:
>                 frontend_type = ZMQ_XREP;   //  Client
>                 backend_type  = ZMQ_XREQ;   //  Service
>                 break;
>             case ZMQ_FORWARDER:
>                 frontend_type = ZMQ_SUB;    //  Subscriber
>                 backend_type  = ZMQ_PUB;    //  Publisher
>                 break;
>             case ZMQ_STREAMER:
>                 frontend_type = ZMQ_PULL;   //  Puller
>                 backend_type  = ZMQ_PUSH;   //  Pusher
>                 break;
>             default:
>                 return (1);             //  Invalid device
>         }
>         //  Create sockets, configure them, and start the device
>         zmq::context_t context (1);
>         zmq::socket_t frontend (context, frontend_type);
>         zmq::socket_t backend (context, backend_type);
>         if (frontend_type == ZMQ_SUB)
>             frontend.setsockopt (ZMQ_SUBSCRIBE, "", 0);
>         frontend.bind (argv [2]);
>         backend.bind (argv [3]);
>         zmq::device (device, frontend, backend);
>
> As you can see I'm using ZMQ_PUSH and ZMQ_PULL in place of
> ZMQ_DOWNSTREAM and ZMQ_UPSTREAM.  It seems to work.  A node pulls
> data, works on it, and pushes it on.  So nodes are pullers, or
> pushers, or both.  It's short, verbish (like the other socket types)
> and feels clear.
>
> If there are no outright objections after a day or so I'll start to
> deprecate ZMQ_DOWNSTREAM/UPSTREAM and replace with ZMQ_PUSH/PULL.
> We'll keep the old definitions around, of course, this does not break
> the ABI.
>
> -Pieter
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>   




More information about the zeromq-dev mailing list