Request/Reply Pattern

Request/reply is a common interaction pattern, which combines both one-to-many and one-to-one communication.

In order to send a message to an inbox, a publisher must have a token representing that inbox, which it receives from the program that created the inbox. Cooperating programs can use a handshake sequence to arrange inboxes for one-to-one communication. The following diagram illustrates this pattern in a request/reply interaction.

The server program (Serv) creates a subscriber object (S) to receive request messages from clients.

A client program (Rqst) creates an inbox subscriber object (I) to receive replies from the server.

The client sends a request message, including a token representing inbox I.

The server uses the token to send a one-to-one reply message to inbox I at the client.

Handshake to Arrange Inbox Communication

Notice that the client publishes the request message one-to-many, but the server sends the reply one-to-one.