[zeromq-dev] fun with Java API
Peter Friend
pfriend at gehrytech.com
Fri Nov 16 02:39:39 CET 2012
Thanks, I've started just using ZMQ.* now as well. Got the javadocs built via maven as well.
Peter
From: zeromq-dev-bounces at lists.zeromq.org [mailto:zeromq-dev-bounces at lists.zeromq.org] On Behalf Of Joshua Foster
Sent: Thursday, November 15, 2012 3:23 PM
To: ZeroMQ development list
Subject: Re: [zeromq-dev] fun with Java API
The bindings have JavaDoc. You can generate it with the maven build. I don't use the Z* objects. I usually use the ZMQ.*
ZMQ.Context context = ZMQ.context(1);
etc...
Joshua
[cid:image001.jpg at 01CDC358.2FF1B340]
Peter Friend<mailto:pfriend at gehrytech.com>
Thursday, November 15, 2012 5:13 PM
Perhaps I have missed it, but as far as I can tell there is no up-to-date reference for the Java zeromq bindings. But that's a minor issue as I can RTFS...
This has been a source of annoyance:
public ZContext() {
context = null; // Don't create Context until create 1st 0MQ socket
sockets = new CopyOnWriteArrayList<Socket>();
ioThreads = 1;
linger = 0;
main = true;
}
I am not sure why the context is not created at this point, but it can cause problems if you have an object which has callback hooks for registering/unregistering the sockets on a Poller. I create my objects which create their sockets and manage their connections, but I need to create a Poller before that point whether I am passing in the Poller explicitly, or referring to a global copy from an overridden method. Creating a socket and then ditching it is a workaround, but is annoying and you have to have a loud comment there so someone doesn't accidentally delete your obviously lame code which is creating a socket then immediately closing it. I am proposing this solution:
public Context getContext() {
if (isMain() && context == null)
context = ZMQ.context(ioThreads);
return context;
}
Of course if you want >1 thread you have to set that value before calling createSocket() or getContext().
Cheers,
Peter
_______________________________________________
zeromq-dev mailing list
zeromq-dev at lists.zeromq.org<mailto:zeromq-dev at lists.zeromq.org>
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20121115/dd5d2ad6/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 770 bytes
Desc: image001.jpg
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20121115/dd5d2ad6/attachment.jpg>
More information about the zeromq-dev
mailing list