liveBook · Manning

Point-to-point communication

As explained in Microservices Patterns, Second Edition

A point-to-point channel delivers each message to exactly one consumer among those reading from the channel.

A point-to-point channel delivers each message to exactly one of the consumers reading from it. Use it for one-to-one interactions, such as sending a command to a service. A publish-subscribe channel instead delivers each message to all subscribed consumers, making it a typical choice for events. section 8.3.1

A channel abstracts the messaging technology. A broker typically receives and stores messages before delivering them, but different brokers make different trade-offs. Selecting one consumer for a message is separate from deciding what delivery guarantees the channel must provide. section 8.3.1 section 8.3.3

Request and reply

A client sends a command containing an operation and parameters to a point-to-point channel owned by a service. The command includes a reply-channel header and a message identifier. The service sends the outcome to the reply channel, with a correlation ID matching the request identifier. The client uses that ID to match the reply to the request. Messaging is inherently asynchronous, although the client could block while waiting. section 8.3.2

Figure 8.13 Implementing asynchronous request/response by including a reply channel and message identifier in the request message. The receiver processes the message and sends the reply to the specified reply channel.
RequestReply

The flow shows how the reply channel and message identifier connect a request to its response. section 8.3.2

For a one-way notification, the client sends a message, typically a command, to the service’s point-to-point channel. The service processes it without sending a reply. section 8.3.2

Define channel requirements before choosing a messaging technology:

  • Specify delivery guarantees and whether messages must arrive in order. section 8.3.3
  • Determine whether competing consumers are needed and whether messages must survive broker crashes or consumer disconnections. section 8.3.3
  • Set scalability and end-to-end latency requirements, then select a technology that fits the channel. section 8.3.3
Table 8.4 Each message broker implements the message channel concept in a different way.

Point-to-point channel

Publish-subscribe channel

ActiveMQ

Queue

Topic

Apache Kafka

Topic

Topic

RabbitMQ

Exchange + Queue

Fanout exchange and a queue per consumer

AWS Kinesis

Stream

Stream

AWS SQS

Queue

-

AWS SNS

-

Topic

Broker implementations differ: for example, a point-to-point channel maps to a queue in ActiveMQ and to an exchange plus queue in RabbitMQ. section 8.3.3

How Microservices Patterns, Second Edition covers it

How deep it goes
Defines single-consumer delivery and works through request-reply routing, correlation, and channel-selection requirements.
Examples
Illustrates a command and correlated reply, plus a one-way notification without a reply.
What you can do after
Evaluate channel requirements and choose between point-to-point and publish-subscribe before selecting a messaging technology.
How it connects
Connects point-to-point communication with publish-subscribe, asynchronous request-response, correlation identifiers, and competing consumers.

Also explained in

Compare how 2 books explain point-to-point communication →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Microservices Patterns, Second Edition. The section links point to the parts of the book it draws on.