[zeromq-dev] ZMQ Java - Best practice to clean when exiting
rails
stammailbox at gmail.com
Tue Nov 18 10:26:06 CET 2014
Thanks.
But if I look at the jeromq code - I see inside ZContext.destroy a call
for destroySocket (to each socket ) which
s.setLinger(linger);
s.close();
sockets.remove(s);
And then It even calls
sockets.clear(); and context.term();
So - Am i safe by calling the java (jeroMQ ) implementation of
context.destroy
On Tue, Nov 18, 2014 at 10:25 AM, Pieter Hintjens <ph at imatix.com> wrote:
> 1. set linger = 0 on all sockets
> 2. close all sockets
> 3. terminate context
>
> On Tue, Nov 18, 2014 at 9:10 AM, rails <stammailbox at gmail.com> wrote:
> > In ZMQ zguide they advice to always clean up when task ends. I am a bit
> > confused regarding the best practice.
> >
> > First
> >
> > ... even if you close all sockets, zmq_ctx_destroy() will by default wait
> > forever
> > ... Finally, destroy the context
> > ... This will cause any blocking receives or polls or sends in attached
> > threads
> > to return with an error. Catch that error, and then set linger on,
> and
> > close sockets in that thread,
> >
> > So do I need to close? destroy? all sockets before I destroy the context?
> > Looking at the context.destroy() I see it calls linger and close on each
> > socket.
> >
> > How should I terminate my ZMQ resources?
> >
> >
> > _______________________________________________
> > 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20141118/caa90477/attachment.htm>
More information about the zeromq-dev
mailing list