libzmq的纯Java实现(http://zeromq.org)。
ipc://协议仅在jeromq之间工作(在内部使用tcp://127.0.0.1:port)。
证券
与本机libzmq相比,性能并不算太差。
tipc://协议。找不到Java实现。
GSSAPI机制尚未实施。
TCP KeepAlive Count,Idle,Interval不能通过Java设置,而是作为OS级别设置。
仍然不支持中断线程:库不是Thread.interrupt安全的。
欢迎你的贡献!有关贡献过程和有用的开发任务的详细信息,请参见 CONTRIBUTING.md 。
将其添加到Maven项目的pom.xml:
pom.xml
<dependency> <groupId>org.zeromq</groupId> <artifactId>jeromq</artifactId> <version>0.5.1</version> </dependency> <!-- for the latest SNAPSHOT --> <dependency> <groupId>org.zeromq</groupId> <artifactId>jeromq</artifactId> <version>0.5.2-SNAPSHOT</version> </dependency> <!-- If you can't find the latest snapshot --> <repositories> <repository> <id>sonatype-nexus-snapshots</id> <url>https://oss.sonatype.org/content/repositories/snapshots</url> <releases> <enabled>false</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories>
要从pom.xml生成ant构建文件,请发出以下命令:
mvn ant:ant
以下是如何实现打印收到的消息的服务器,并使用“Hello,world!”来响应它们:
import org.zeromq.ZMQ; import org.zeromq.ZContext; public class hwserver { public static void main(String[] args) throws Exception { try (ZContext context = new ZContext()) { // Socket to talk to clients ZMQ.Socket socket = context.createSocket(ZMQ.REP); socket.bind("tcp://*:5555"); while (!Thread.currentThread().isInterrupted()) { // Block until a message is received byte[] reply = socket.recv(0); // Print the message System.out.println( "Received: [" + new String(reply, ZMQ.CHARSET) + "]" ); // Send a response String response = "Hello, world!"; socket.send(response.getBytes(ZMQ.CHARSET), 0); } } } }
zguide示例的JeroMQ 翻译是推荐用法的一个很好的参考。
(请注意, zguide 中的Java示例已过时,并不一定反映当前使用JeroMQ的建议做法。)
有关API级文档,请参阅 Javadocs 。
此repo还有一个 doc 文件夹,其中包含各种“如何做X”文件夹。有关使用JeroMQ的各种主题的指南和其他有用信息。
所有源文件的版权均为©2007-2018贡献者,如AUTHORS文件中所述。
根据Mozilla Public License 2.0的条款授予免费使用此软件。有关详细信息,请参阅JeroMQ发行版附带的文件LICENSE。
LICENSE