I'm reading the ZeroMQ Guide and came across the following passage in regards to the ROUTER
socket and identities:
An application that uses a
ROUTER
socket to talk to specific peers can convert a logical address to an identity if it has built the necessary hash table. BecauseROUTER
sockets only announce the identity of a connection (to a specific peer) when that peer sends a message, you can only really reply to a message, not spontaneously talk to a peer.This is true even if you flip the rules and make the
ROUTER
connect to the peer rather than wait for the peer to connect to theROUTER
. However you can force theROUTER
socket to use a logical address in place of its identity. Thezmq_setsockopt
reference page calls this setting the socket identity.
According to this passage, "you can only really reply to a message, not spontaneously talk to a peer", meaning a ROUTER
can't send a message to a specific DEALER
, but the next sentence implied that you can if you force the router socket to use a logical address: "However you can force the ROUTER
socket to use a logical address in place of its identity". This part confuses me because they just said that you cant spontaneously send messages from a router to a dealer, but now they claim you can. If you follow this link to the guide, you'll see that after this passage, they say "It works as follows", but the steps they give don't seem to clear up how to send a spontaneous message from a ROUTER
to a specific DEALER
and return a response back to the original ROUTER
.
My question: Is it possible for a single ROUTER
socket to send a request to a specific DEALER
(Out of many) socket and the DEALER
send the result of the request back to the ROUTER
? And if it is possible, how can this be done?
Follow up question: If this is not possible, is there a better combination of sockets to approach this?
Below is a crude diagram of my intended design:
Basically, the client send a request to 1 specific server, that server processes the request and returns the result of the request to the client. The client now has that result, and it knows what server it was processed on.