[zeromq-dev] sending from multiple threads

Lineker Tomazeli lineket at gmail.com
Thu Dec 1 16:23:46 CET 2016


Hi guys,

I have been reading zeromq list for a while now but is the first time I'm
asking something. So nice to meet you all :)

In the zeromq documentation/book is very clear that we shouldn't be
handling zeromq sockets from multiple threads without doing a memory
barrier.

*First question:*

What is the recommended pattern to have one thread responsible for
connecting, binding and polling messages from sockets. And have multiple
thread sending messages.

My first approach was to have a threadsafe producer/consumer queue where
sender threads would push on the queue and the "zeromq" thread would pick
from queue and send through the wire. This works but I find it redundant
and memory inefficient.

My second approach (on which I used netmq) was to schedule a "send a
message" task on the Poller. This guaranteed that the task ran in the same
thread as the poller.


What would be the correct approach if I use clrzmq4 ?


*Second question :*

What is the correct approach for a "zeromq" thread to notify other threads
that I new message was received ?
 - raise an event on another thread?
 - use a threadsafe producer/consumer queue to dump receiving message ?


*Third question:*

Zeromq is truly a great and fun framework to work with. I was wondering why
there not so much buzz about it? Do you know companies using in production?



Lineker Tomazeli
tomazeli.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20161201/1797a232/attachment.htm>


More information about the zeromq-dev mailing list