纯java ZeroMQ 客户端?
我正在尝试使用 ZeroMQ 的 pub sub 消息传递,但客户端要求代码全部为 Java。我知道 ZeroMQ 有一个 Java 绑定,但仍然依赖于 ac 库,因此我无法使用它。是否有我可以用来连接到服务器的 ZeroMQ 客户端,或者实现是否足够简单,我可以自己完成?
I am trying to use ZeroMQ's pub sub messaging, but the client side requires the code to be all Java. I understand that ZeroMQ has a Java binding but that still relies on a c library, therefore I am unable to use it. Is there a ZeroMQ client I can use to connect to the server, or is the implementation simple enough for me to do myself?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
我正在研究纯java ZeroMQ。
https://github.com/miniway/jeromq
即使它还处于早期阶段,可能不太适合现在的生产使用情况。
但我希望它能有所帮助,因为我是满怀热情地做的。
I'm working on pure java ZeroMQ.
https://github.com/miniway/jeromq
Even it is very early stage and might not quite fit for production usage right now.
But I hope it would help, as I made it with a passion.
Zeromq 网站在以下页面上声称支持 Android:
http://www.zeromq.org/distro:android
其中包括为 android 预构建的 Zeromq 压缩包,使用 NDK(本机开发工具包)将 Java 应用程序与标准 C 库桥接起来。
The zeromq web site claims support for android on the follow page:
http://www.zeromq.org/distro:android
which includes a tarball of zeromq pre-built for android, using the NDK (Native Development Kit) which bridges Java apps to standard c libraries.
截至今天,我认为可以肯定地假设您的问题的答案是否。
纯 Java 客户端需要使用与本机 C++ 实现相同的有线协议;该协议的文档尚未完成,我上次检查时已在 0MQ 开发人员 TODO 列表中。
As of today, I think it is safe to assume that the answer to your question is no.
A pure Java client would need to use the same wire protocol as the native C++ implementation; documenting this protocol has not been done yet and was on the 0MQ developers TODO list last time I checked.
注意:我假设您已成功安装 ZeroMQ 和 google protoc
我有一个示例,其中我使用 google protocol buffer 从 ZeroMQ 发布者向订阅者发送一些消息。
test.proto 文件
现在首先编译它与 protoc 编译器一样
所以这将在当前目录中生成
TestProtos.java
文件/com/example/tutorial
文件夹--------------------------------协议结束缓冲步骤--------------------------
发布者代码是
文件名:Publisher.java
订阅者代码是
文件名:Subscriber.java
这就是全部..您已经完成了代码..
现在只需运行这些发布者和订阅者代码..
Note : I am assuming that you have installed ZeroMQ and google protoc successfully
I have one example where I am sending some messages from ZeroMQ Publisher to Subscriber using google protocol buffer..
test.proto file is
now first compile it with protoc compiler as
So this will generate
TestProtos.java
file in your current directories/com/example/tutorial
folder---------------------------------end of protocol buffer steps--------------------------
Publisher code is
file name : Publisher.java
Subscriber Code is
file name : Subscriber.java
That is all..you are done with your code..
Now just run these Publisher and subscriber codes..
目前还没有
0mq
的纯 Java 实现。正如你所说,有一个 Java 语言绑定,但它需要一个本机库才能运行。实现该库的纯 Java 替代品并非易事。There is currently no pure Java implementation of
0mq
. As you say, there is a Java language binding but it requires a native library to function. A pure Java replacement for the library would not be trivial to implement.在 http://rfc.zeromq.org/spec 上有一个关于 ZeroMQ 使用的线路协议的简短规范: 13..这样您至少应该能够编写代码的协议部分。您仍然需要编写处理 ZeroMQ 套接字之类的部分。
There is a short spec on the wire protocol used by ZeroMQ at http://rfc.zeromq.org/spec:13. With that you should at least be able to write the protocol portions of the code. You would still need to write the parts that deal with ZeroMQ sockets and whatnot.
javazmq 项目于 2011 年 8 月启动,声称要用纯 Java 实现 ZeroMQ 的子集。目前不确定其完整性。
The javazmq project started in Aug of 2011 claims to implement a subset of ZeroMQ in pure Java. Not sure of the completeness of it at this point.