The request message should contain a Return Address that indicates where to send the reply message.

This way, the replier does not need to know where to send the reply, it can just ask the request. If different messages to the same replier require replies to different places, the replier knows where to send the reply for each request. This encapsulates the knowledge of what channels to use for requests and replies within the requestor so those decisions do not have to be hard coded within the replier. A Return Address is put in the header of a message because it’s not part of the data being transmitted.

...

Example: Golang Channels (NEW)

In Go, channels are first-class language constructs, making it easy to specify a channel as return address by including a field of type chan in the structure to be passed as the request:

type Request struct {
data []int
resultChan chan int
}

A function handling requests can now publish responses to the channel provided in the Request structure:

My new book describes how architects can play a critical role in IT transformation by applying their technical, communication, and organizational skills with 37 episodes from large-scale enterprise IT.

Parts of this page are made available under the Creative Commons Attribution license. You can reuse the pattern icon, the pattern name, the problem and solution statements (in bold), and the sketch under this license. Other portions of the text, such as text chapters or the full pattern text, are protected by copyright.