Publish/subscribe is an asynchronous, one-to-many interaction style. A publisher sends a message to a publish-subscribe channel, which delivers it to all subscribed consumers. Services commonly use this style to publish events without waiting for an immediate response. section 8.1.1 section 8.3.1
Use a publish-subscribe channel when multiple services need the same notification. Use a point-to-point channel when exactly one consumer should process a message, such as a command. Messaging alone does not guarantee loose runtime coupling: a client can still block while waiting for a response. section 8.3.1 section 8.1.1
Order events and saga choreography
An Order Service can own an Order channel and publish domain events to it; interested services subscribe to that channel. In a choreography-based saga, an OrderCreated event triggers the Customer Service to attempt to reserve credit. Its resulting event then triggers the Order Service to approve or reject the order. section 8.3.2 section 10.1.1
Define each channel’s requirements before choosing a messaging technology. Delivery guarantees, ordering, competing consumers, persistence, durability, scalability, and latency all affect the choice. A broker commonly implements the channel, although brokerless messaging is also possible. section 8.3.3 section 8.3.1
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 |
Compare how messaging technologies implement publish-subscribe and point-to-point channels. section 8.3.3
When multiple responses are needed, publish/async responses combines publish/subscribe with request/response: the published message specifies a reply channel, and the client uses correlation IDs to match replies to the request. section 8.3.2







