Can someone explain an example request from a broker-responder-responder?

I refer to the "Request-Reply Broker" in the Zeromq documentation: http://zguide.zeromq.org/chapter:all

I get the general meaning of the application: it acts as an intermediary and sends messages from the client to the server and vice versa.

What I am not getting is how it ensures that the correct response from the server is sent to the correct client who originally made the request. I don't see anything in the code example that does this.

Now in the example, they send only one message (hello) and 1 response (peace), so even if the messages are mixed, it does not matter, but I assume that the test client and server are kept intentionally simple.

Any thoughts are welcome ...

+6
zeromq
source share
2 answers

All zeromq sockets implicitly have an identifier associated with them. (This identifier can be obtained using zmq_getsockopt () .)

For bidirectional socket types, not XREQ or XREP, this identity is automatically transferred as part of every message sent over the socket. The REP socket uses this identifier to redirect the response message to the corresponding socket. This leads to automatic routing.

Under the hood, identifiers are transmitted through multi-page messages. The first message in a multi-page message will contain the socket identifier. An empty message will follow, followed by all messages specified by the user. REQ and REP sockets automatically process these prefix messages. However, if you use XREQ or XREP sockets, you need to fill in these messages yourself.

If you are looking for "identity" in the ZMQ Guide , you should find all the details that you will ever want to learn about how identifiers and socket operation.

+9
source share

Well in chapter 3, they suddenly explain that there is a fundamental concept of an β€œenvelope” that invqubly req / resp uses.

This explains how it works.

+1
source share

All Articles