Hi all.

I'm developing an application using 0MQ and the Java bindings and wanted to ask 
the community a question:  Has anyone found an elegant way to extend a 0MQ 
message loop into a more general purpose event loop?

I'll be more specific.  I have a thread that receives messages on a set of 
sockets via poll() and sends messages in response to those received messages.  
Pretty standard so far.  Occasionally, however, another thread will generate 
some event in response to which the first thread needs to send a message on one 
of its sockets.  This other thread is not always under my control and is not 
even always the same thread (i.e. third party library) and so I have no way to 
give a socket to this other thread so that it can send my first thread a 
message notifying it of the event.  How do I get information about this event 
into my first thread so it can send its message?

The only  solution I can think of (which is ugly) is to break out of the poll() 
call periodically and check an event queue shared by both threads.

Other possibilities would be some sort of way to break the first thread out of 
poll() via another thread so that it can check the event queue immediately, or 
to somehow incorporate the 0MQ sockets into the Java NIO selector framework 
(which is interruptible), again so my first thread can check the event queue 
immediately.  It is not obvious to me how either of these would be done, if 
they can be done at all.

Has anyone run into this situation using the Java bindings, and if so did you 
find a good solution?

Thanks,
Aja Walker
_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to