Akka ZeroMQExtension使用一个zeromq套接字创建多个连接
Is it possible to create socket with multiple outgoing (ingoing) connections using ZeroMQExtensions?
是否可以使用ZeroMQExtensions创建具有多个传出(进入)连接的套接字?
More about multiple connections in ZeroMQ guide.
有关ZeroMQ指南中多个连接的更多信息。
upd: I can't see equavalent sample with ZeroMQExtensions. In 0MQExtensions documnetation i found:
upd:我看不到具有ZeroMQExtensions的等价样本。在0MQExtensions documnetation中,我发现:
newPubSocket(socketParameters: Array[SocketOption]): ActorRef
Java API factory method to create the actor representing the ZeroMQ Publisher socket. You can pass in as many configuration options as you want and the order of the configuration options doesn't matter They are matched on type and the first one found wins.
Java API工厂方法,用于创建表示ZeroMQ Publisher套接字的actor。您可以根据需要传入任意数量的配置选项,配置选项的顺序无关紧要。它们在类型上匹配,第一个找到胜利。
PS: I don't known scala and just started reading akka documentation to understand I need Akka or not.
PS:我不知道scala并且刚开始阅读akka文档以了解我是否需要Akka。
1 个解决方案
#1
0
I found solution (it was not intuitive but works):
我找到了解决方案(它不直观但有效):
ActorRef subSocket = ZeroMQExtension.get(getContext().system())
.newSubSocket(null, new Listener(getSelf()), new Subscribe("health"));
@Override
public void preStart() {
super.preStart();
subSocket.tell(new Connect("tcp://127.0.0.1:1237"));
subSocket.tell(new Connect("tcp://127.0.0.1:1238"));
}
更多相关文章
- 在网页程序或Java程序中调用接口实现短信猫收发短信的解决方案
- javascript(六)js事件绑定浏览器兼容解决方案 attachEvent addEve
- java中多线程安全问题产生&解决方案——同步方法