我正在尝试确定是否有两个例程调用相同的ZeroMQ套接字,如果从routine1的socket.recv()返回,则套接字将知道返回到routine1(routine2、... routinen同样)。因此......使用具有请求/响应语义的消息总线,在go中处理这个最好的模式是什么? 如果有帮助的话,请考虑简单海盗模式,并使用zeromq在该模式中实现RPC样式调用集。
Socket; //zeromq socket
//routine 1
socket.send(data) // do i need some identifier here for this routine?
socket.recv() // wait until i get a response from that send
//routine 2
socket.send(data)
socket.recv()
在这种情况下,我不知道 routine1 或 routine2 的响应会先返回。我该如何确保当我收到 socket 的响应时,能够通知正确的接收函数。
谢谢!