[zeromq-dev] Request-reply broker with one worker and many async tasks

Charles Remes lists at chuckremes.com
Wed Nov 6 23:02:03 CET 2013


I'll paste my response from IRC here since it is relevant and I'll add a few more thoughts.

cremes:cosmoharrigan_: how is the response sent back via the callback? If it's via that single DEALER socket and the callback runs in another thread, you need to protect the socket with a mutex.
[3:46pm]cremes:Best to just give each thread its own socket. It's a cleaner design plus it let's you push thread & lock management into zeromq.

If the reply from the callback needs to be routed back to the client, you should continue to use DEALER(client) <-> ROUTER (broker) <-> DEALER (worker). In this case there is a single worker but the message passing works exactly the same.

cr

On Nov 6, 2013, at 3:43 PM, Cosmo Harrigan <cosmo.harrigan at singularityu.org> wrote:

> Hi,
> 
> I want to implement a design similar to the Request-Reply Broker from the zguide (https://raw.github.com/imatix/zguide/master/images/fig17.png) but instead of having multiple workers running ahead of time, I want to have one worker that receives all the requests, and spawns asynchronous operations (tasks) to handle them and send the responses.
> 
> What would be the proper combination of socket types to achieve this?
> 
> Thanks,
> Cosmo Harrigan
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20131106/e7528f62/attachment.html>


More information about the zeromq-dev mailing list