[zeromq-dev] Java API is not notifed of C++ assert failures.

Vladimir & Mihaela puiuvlad at optonline.net
Fri Apr 10 12:57:37 CEST 2009

Hey Martin,

I've been struggling with this for some time now, and I feel I can't go
forward without help.

I have not modified the C++ layer in the previous design, in the sense that
the Jzmq object still has an array of api_thread_t objects and I am still
exposing them via the thread id (index in the api_thread_t array) in the
Jzmq object methods (I will hide them later). In Java I have added an
ApiProxy object that uses a ThreadLocal to generate a private thread id
unique per thread. I also wrapped the Jzmq methods and exposed them without
the thread id in the ApiProxy object, like so:

  private native int createQueue (int apiThreadId, String queue, int scope,
String nic);

  public int createQueue (String queue, int scope, String nic) {
    return _jzmq.createExchange(_proxyId, queue, scope, nic);

This allows me to execute in the main thread:

    _jzmq = new Jzmq(zmqHost, 2);

    Jzmq.JApiProxy api1 = _jzmq.getApiProxy();
    _xId = api1.createExchange("E", Jzmq.SCOPE_LOCAL, host);
    api1.bind("E", "disQ");

and in a different thread:

    Jzmq.JApiProxy api2 = _jzmq.getApiProxy();
    api2.createQueue("Q", Jzmq.SCOPE_LOCAL, _host);
    api2.bind("disX", "Q");

As before, in one process I create a global exchange and a global queue and
in the other process I create a local exchange and a local queue, and bind
the opposite objects.

If I use the old Jzmq methods (with the thread id) then all's OK, but if I
use the wrapper methods (which ultimately get translated into the same calls
to the old methods) the second process dies when trying to bind. It is as if
the global objects created by the first process are not recognized if I call
them in the new way while being recognized if I call them in the old way.

17:17:42,684  INFO Dispatcher:43 -
createExchange _proxyId=0, exchange=disX, nic=
createQueue _proxyId=0, queue=disQ, nic=

17:17:50,445  INFO Process:69 - sim
createExchange _proxyId=0, exchange=E, nic=
bind _proxyId=0, exchange=E, queue=disQ <= this process dies here

Is there a way to trace what's happening in the zmq_server? What objects are
registered, and by which process? Any other suggestion to get past this


More information about the zeromq-dev mailing list