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

Vladimir & Mihaela puiuvlad at optonline.net
Wed Apr 1 03:18:40 CEST 2009

Hey Martin,

I agree with you that the passing of the api_thread_id as the first
parameter for all meaningful functions (createQUeue, createExchange, bind,
send, receive) is not neat. However, I think it's the most efficient way -
not too many Java to C++ marshalling of params. The messaging code is
already encapsulated and there are only a couple of places where one would
need to pay close attention.

You mention in one of the previous posts: "Constructor has to take 'number
of threads' parameter and return N 'API' objects instead of a single one."

Along these lines I could return an array of api proxies, or an ArrayList of
proxies. In either case in Java I would need to get each of the proxies
using code like.

  ApiProxy[] apiProxies = (new Jzmq(zmqHost, 2)).getProxies();
  ApiProxy api1 = apiProxies[0];
  ApiProxy api2 = apiProxies[1];


  ArrayList<ApiProxy> apiProxies = (new Jzmq(zmqHost, 2)).getProxies();
  ApiProxy api1 = apiProxies.get(0);
  ApiProxy api2 = apiProxies.get(1);

and then use api1 in one thread and api2 in the other.

Not sure if this is neater; definitely it is less efficient.

Alternatively I could create the object stubs in Java and invoke
api_thread_t::create in the ApiProxy constructor.

  Jzmq jzmq = new Jzmq(zmqHost, 2);
  ApiProxy api1 = new ApiProxy(jzmq);
  ApiProxy api2 = new ApiProxy(jzmq);

but in this case one would need to make sure the counter in the Jzmq
constructor matches the number of proxies created with new. Neater, agreed.

So, which one do you prefer? Do you have any other suggestions?

WRT loading the libzmq in addition to jzmq, I just did a search for the
error that I was getting trying to run my code and the recommended solution
was just this. I think this will run under Unix/Linux as well without

Finally, I am not familiar with MIT licensing. Briefly, what do I need to


More information about the zeromq-dev mailing list