[zeromq-dev] zmq_socket and threads

Nishant Mittal nmittal at rblt.com
Thu Jan 3 16:36:48 CET 2013


Pieter, we are porting legacy code from ActiveMQ to ZeroMQ and want minimal
changes to architecture. I am now creating sockets inside the thread.

thanks
Nishant


On Thu, Jan 3, 2013 at 5:11 AM, Pieter Hintjens <ph at imatix.com> wrote:

> On Wed, Jan 2, 2013 at 10:23 PM, Nishant Mittal <nmittal at rblt.com> wrote:
>
> > the reason is ...
> > 1) my application creates 5 threads, does some calcs and then the threads
> > exit
> > 2) this is done every minute. so every minute 5 new threads are created.
> > 3) I think i will run into a file descriptor issue if i create sockets
> > inside the thread (every time the thread is launched). so planning to
> create
> > 5 sockets when my application starts and then use 1 socket from 1 thread.
>
> You are solving entirely the wrong issue here.
>
> Your architecture is wrong; creating and destroying threads and
> sockets is a bad idea and unnecessary. Create your worker threads at
> the start, send them work when it's available, and leave them running.
> Create sockets in threads, use them locally, and _DO NOT_ share data,
> especially sockets, between threads.
>
> Sharing sockets between threads because you're afraid to create new
> sockets is... very poor.
>
> -Pieter
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>



-- 
*Nishant Mittal*
Director, Product Development
*Rosenblatt Securities Inc*.
20 Broad Street
New York, NY 10005

Direct: 212-607-3159
Mobile: 646-504-2629
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20130103/0ff11773/attachment.htm>


More information about the zeromq-dev mailing list