I'm investigating zeromq as a message passing solution in a java project, but I find the instructions on java binding somewhat difficult to follow. http://www.zeromq.org/bindings:java
I am unfamiliar with java bindings, so these may be stupid questions, but can someone help me understand:
I feel like the instructions provided on zeromq require base familiarity with building C projects that I lack, so perhaps I am just being dense, but this seems like a lot of work.
ZeroMQ as a library works through sockets by following certain network communication patterns. It is designed to work asynchronously, and that's where the MQ suffix to its name comes - from thread queuing messages before sending them.
A ØMQ context is thread safe and may be shared among as many application threads as necessary, without any additional locking required on the part of the caller. Individual ØMQ sockets are not thread safe except in the case where full memory barriers are issued when migrating a socket from one thread to another.
As a fellow user of the Java binding of ZeroMQ, I sympathize. ZeroMQ is definitely one of the more challenging Java dependencies to manage. In it's heart of hearts, ZeroMQ is native C code and the Java binding is a (relatively) light weight wrapper around a JNI interface to the core ZeroMQ library and this is why it is complex to deploy.
As an aside - if ZeroMQ is a good match for your application, it's well worth the trouble because there really is nothing quite like it. Unfortunately this means you need to go through all these steps to get it working so you can decide if it is what you really need.
ZeroMQ for Java is based on three components:
Will jars I build on one machine work on another system? I need this application to be portable.
Yes. The jar will be portable. You can build it on any machine and deploy it on any other. However thats the easy part. The hard part is creating the various DLLs that are required and those are not portable. Let's say you want to support Windows, Mac and Fedora Linux. You will need native development environments on Windows, Mac and Fedora and build the DLLs for each platform you want to support.
I don't know enough about Linux to say whether a DLL built on one distribution (say Fedora) will run on another (say Debian). If not, then you have more work ahead.
Anyhow, your application will be portable - ZeroMQ and JZMQ can run on a huge number of platforms - but you will need to have tight control over your deployment process to ensure that when you install each platform, the jar and the appropriate set of DLLs are installed, and they are installed in the right place.
Why do I need to install anything?
Technically you don't. But I think they recommend doing the make install
step so that the include and library files are where the compilers expect them and also so that Java can load them when it is time to run your program.
If so, why do I need to build my own jars to begin with?
I'm not a committer so I cannot say for sure. I expect part of it is developer efficiency - they would rather be improving the code than creating jars for users who could create the jars themselves.
More importantly - since the jars are not enough and you have to build the DLLs anyways, it makes more sense to build the jars and DLLs together. That way you are certain the JNI wrapper has exactly the right native methods implemented in C to match the native declarations in the Java wrapper class.
Good luck. Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With