[zeromq-dev] Need help on java jni binding -- ZMQ.Poller.register(SelectableChannel, int)

artemv zmq artemv.zmq at gmail.com
Tue Jul 8 16:49:40 CEST 2014


hi

I'm on java, using jzmq-3.2.2, and jni binding v3.  Ran into troubles with
poller and its .register(SelectableChannel, int) function. The problem is
that target SelectableChannel  once registered  can render only one
occurrence of .pollin() == true. Despite the fact that my External
application bombarding this channel with messages.

Here's my code:

public void run() {
for (;;) {
ZMQ.Poller poller = new ZMQ.Poller(1);
int i = poller.register(socketChannel, POLLIN);
poller.poll(1000);
LOGGER.info("### poller.pollin(" + i + ")=" + poller.pollin(i));
if (poller.pollin(i)) {
try {
MySelectionKey selectionKey = new MySelectionKey(socketChannel);
selectionKey.attach(nioSocketChannel);
read(selectionKey);
} catch (ZmqOpenAPINioWorkerException e) {
LOGGER.warn("### Fail: " + e, e);
}
}
}
}


So, I every time register socketChannel on new poller  and polling it.
External client sending messages constantly, so I should get in my code
always poller.pollin(0) == true, but unfortunately I get this only once.


Any guideline would be much appreciated.

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20140708/4d3d5b2a/attachment.htm>


More information about the zeromq-dev mailing list