[zeromq-dev] Need help on java jni binding -- ZMQ.Poller.register(SelectableChannel, int)
artemv zmq
artemv.zmq at gmail.com
Tue Jul 8 16:51:40 CEST 2014
The part:
MySelectionKey selectionKey = new MySelectionKey(socketChannel);
selectionKey.attach(nioSocketChannel);
read(selectionKey);
is just dummy internal stuff. Pls. ignore it for this question.
2014-07-08 17:49 GMT+03:00 artemv zmq <artemv.zmq at gmail.com>:
> 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/62aff180/attachment.htm>
More information about the zeromq-dev
mailing list