了解zeromq java绑定 [英] Understanding zeromq java binding

查看:130
本文介绍了了解zeromq java绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在调查zeromq作为java项目中的消息传递解决方案,但我发现有关java绑定的说明有点难以理解。 http://www.zeromq.org/bindings:java

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

我不熟悉java绑定,所以这些可能是愚蠢的问题,但有人可以帮助我理解:

I am unfamiliar with java bindings, so these may be stupid questions, but can someone help me understand:


  1. 为什么我需要安装任何东西?

  2. 我在一台机器上构建的jar是否会在另一个系统上运行?我需要这个应用程序是可移植的。

  3. 如果是这样,为什么我需要自己开始构建自己的jar?

我觉得zeromq上提供的说明需要熟悉构建我缺乏的C项目,所以也许我只是在密集,但这似乎很多工作。

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 Java绑定的同伴,我表示同情。 ZeroMQ绝对是要管理的更具挑战性的Java依赖项之一。在它的核心,ZeroMQ是本机C代码,Java绑定是围绕到核心ZeroMQ库的JNI接口的(相对)轻量级包装器,这就是它部署起来很复杂的原因。

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.

顺便说一句 - 如果ZeroMQ非常适合您的应用程序,那么它非常值得一试,因为它确实没有什么比这更好的了。不幸的是,这意味着您需要完成所有这些步骤以使其正常工作,以便您可以决定它是否真正需要。

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基于三个组件:

ZeroMQ for Java is based on three components:


  • libzmq - 核心ZeroMQ库(DLL - 任何语言都需要,而不仅仅是Java)

  • jzmq - Java绑定的本机部分(DLL)

  • zeromq.jar - Java绑定的Java部分(JAR)


我在一台机器上构建的jar是否会在另一个系统上运行?我需要这个应用程序是可移植的。

Will jars I build on one machine work on another system? I need this application to be portable.

是的。罐子是便携式的。您可以在任何计算机上构建它并将其部署在任何其他计算机上。不过这很容易。困难的部分是创建所需的各种DLL,这些DLL不可移植。假设你想支持Windows,Mac和Fedora Linux。您将需要Windows,Mac和Fedora上的本机开发环境,并为您要支持的每个平台构建DLL。

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.

我对Linux的了解还不足以说明构建在一个发行版(比如说Fedora)上的DLL是否会运行在另一个发行版上(比如说Debian)。如果没有,那么你还有更多工作要做。

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.

无论如何,你的应用程序将是可移植的 - ZeroMQ和JZMQ可以在大量平台上运行 - 但你需要严格控制您的部署过程,以确保在安装每个平台时,安装jar和相应的DLL集,并将它们安装在正确的位置。

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?

从技术上讲,你没有。但我认为他们建议执行 make install 步骤,以便include和库文件是编译器所期望的位置,以便Java可以在运行时加载它们你的程序。

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?

我不是提交者所以我不能肯定地说。我希望它的一部分是开发人员效率 - 他们宁愿改进代码而不是为可以自己创建jar的用户创建jar。

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.

更重要的是 - 因为罐子是还不够,无论如何你必须构建DLL,将jar和DLL组合在一起更有意义。这样你就可以肯定JNI包装器在C中实现了完全正确的本机方法,以匹配Java包装器类中的本机声明。

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.

这篇关于了解zeromq java绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆