[zeromq-dev] fun with Java API
Joshua Foster
jhawk28 at gmail.com
Fri Nov 16 00:23:18 CET 2012
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
> 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
> 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/ec23bfc9/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: compose-unknown-contact.jpg
Type: image/jpeg
Size: 770 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20121115/ec23bfc9/attachment.jpg>
More information about the zeromq-dev
mailing list