我正在浏览ZeroMQ网站上的示例,所有的示例都不适用于jzmq库。我认为它们可以与其他Java实现一起使用,但我正在研究的项目使用的是jzmq。有没有JZMQ的例子?
具体地说,如何创建轮询器?该示例具有:
context.createPoller(2);在折旧的上下文中有一种方法:
context.getContext().poller();并要求使用构造函数,但ZMQ.Poller构造函数是受保护的。
你应该如何构建一个呢?
发布于 2020-08-27 23:39:38
我找到了一个使用JZMQ 3.1.0库创建轮询器的代码示例。它只是与其他java API稍有不同。
//You use the constructor that takes the number of pollers
ZMQ.Poller poller = new ZMQ.Poller(2);
//then you register your socket contexts
int id1 = poller.register(socket1, ZMQ.Poller.POLLIN);
int id2 = poller.register(socket2, ZMQ.Poller.POLLIN);希望这对其他人有帮助。
https://stackoverflow.com/questions/63607816
复制相似问题