java - Assertion error polling from inside a new thread in ZeroMQ (JeroMQ) -


i have code looks this:

public void handlerequests() {     zmq.poller items = new zmq.poller(1);     items.register(clientendpoint, zmq.poller.pollin);     while (!thread.currentthread().isinterrupted()) {         byte[] message;         items.poll();  // line throws exception.         if (items.pollin(0)) {             message = clientendpoint.recv(0);         }     } } 

it works fine when call directly:

foo.handlerequests(); 

but fails regularly assertion errors if run in new thread:

final runnable listener = worldviewserver::handlerequests; executors.newsinglethreadexecutor().execute(listener); 

the stack trace shown below:

exception in thread "pool-6-thread-1" java.lang.assertionerror @ zmq.mailbox.recv(mailbox.java:113) @ zmq.socketbase.process_commands(socketbase.java:820) @ zmq.socketbase.getsockopt(socketbase.java:258) @ zmq.pollitem.readyops(pollitem.java:107) @ zmq.zmq.zmq_poll(zmq.java:708) @ zmq.zmq.zmq_poll(zmq.java:600) @ org.zeromq.zmq$poller.poll(zmq.java:1618) @ org.zeromq.zmq$poller.poll(zmq.java:1592) @ com.tracelink.worldview.server.head.handlerequests(head.java:68) @ com.tracelink.worldview.server.worldviewserver.handlerequests(worldviewserver.java:236) @ com.tracelink.worldview.server.fsm.enablingaction$$lambda$12/404648734.run(unknown source) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1142) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:617) @ java.lang.thread.run(thread.java:745) 

i'm using java 8 jeromq 0.3.5-snapshot

zmq sockets not threadsafe. have limited ability create socket in 1 thread , use in another, i'm guessing unseen code branch off multiple threads attempting use socket @ same time. that's zmq no-no. generally, should creating sockets in threads they'll used in.

zmq contexts are threadsafe.


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -