[zeromq-dev] finding the right message pattern
Michel Pelletier
pelletier.michel at gmail.com
Wed Sep 12 05:29:34 CEST 2012
In your scenario it sounds like there are many recording devices and a
single master. This is a good setup for DEALER as the devices and
ROUTER as the master. A DEALER works well for the device because it
needs to only send and receive with no knowledge of the address of the
master. A ROUTER is good for the master because it needs to
individually address the devices to send and receive messages from
specific devices.
DEALER and ROUTER are also unbound from the strict
...send->recv->send... statefullness of REQ and REP. You can
interleave any number of send and recv calls in any order. Of course,
you have to keep track of your requests yourself if you need to
preserve the state of some kind of transaction, but that's not hard,
you can keep your requests in a dictionary and that has the added
benefit of allowing you to detect devices that have failed and timed
out. Messages that need no acknowledgement can simply be sent and be
done with it.
As for Python tips, there really isn't much above and beyond the usual
code hygiene and testing practices. pyzmq comes with a lot of cool
stuff and examples, so definitely clone the pyzmq git repo and spend
some time digging around in there.
-Michel
On Tue, Sep 11, 2012 at 5:14 PM, David Kaufman <david.kaufman at gmx.de> wrote:
> Hi,
>
> I'm a little bit confused. Is this the example I should be working
> with http://zguide.zeromq.org/php:chapter3#ROUTER-to-DEALER-Routing ?
> It seems that I'm only able to send messages to the clients (recording
> devices) but not the other way around.
>
> The next example I looked at was
> http://zguide.zeromq.org/php:chapter3#Asynchronous-Client-Server ?
> Which looks awful complicated. Are the extra worker threads on the
> server side really necessary? I want to keep it as simple as possible.
>
> By the way, I'm using python as the programming language. Do you have
> any hints/examples/documentation pointers?
>
> Cheers,
> David Kaufman
>
>
> 2012/9/11 Michel Pelletier <pelletier.michel at gmail.com>:
>> If your master uses a ROUTER socket, it can address each recording
>> device individually to issue it start/stop commands. The devices
>> themselves can use a DEALER socket to both receive/respond to
>> commands, and to send recording data without acknowledgement.
>> Neither DEALER or ROUTER are synchronously bound like REQ/REP.
>>
>> -Michel
>>
>> On Tue, Sep 11, 2012 at 5:21 AM, David Kaufman <david.kaufman at gmx.de> wrote:
>>> Hi ZeroMQ Community,
>>>
>>> I'm currently working on a small project where multiple machines
>>> output data from a recording device (e.g. audio data). Note that a
>>> recording device is just another zeromq capable client. A master
>>> machine collects the output of each recording device. The recording
>>> device is selected, initiated and stopped by the master machine. To
>>> sum up, the master has to communicate with each recording devices in a
>>> bidirectional fashion.
>>>
>>> The request/replay message pattern works but produces unnecessary
>>> overhead since the master machine hast to reply to every data packet
>>> the recording device sends. Is there a cleaner solution, perhaps a
>>> paired socket? Do you have any suggestions?
>>>
>>> Cheers,
>>> David Kaufman
>>> _______________________________________________
>>> zeromq-dev mailing list
>>> zeromq-dev at lists.zeromq.org
>>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>> _______________________________________________
>> zeromq-dev mailing list
>> zeromq-dev at lists.zeromq.org
>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> _______________________________________________
> 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