Skip to content

Commit 0c7f0fe

Browse files
Minor tweaks, marked as reviewed
1 parent d2d73df commit 0c7f0fe

File tree

1 file changed

+25
-33
lines changed
  • nservicebus/messaging/publish-subscribe

1 file changed

+25
-33
lines changed

nservicebus/messaging/publish-subscribe/index.md

Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Publish-Subscribe
33
summary: Subscribers tell the publisher they are interested. Publishers store addresses for sending messages.
4-
reviewed: 2022-08-23
4+
reviewed: 2024-01-17
55
component: Core
66
redirects:
77
- nservicebus/how-pub-sub-works
@@ -17,38 +17,35 @@ related:
1717
- transports/msmq/subscription-authorisation
1818
---
1919

20-
NServiceBus has a built in implementation of the [Publish-subscribe pattern](https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern).
20+
NServiceBus has a built-in implementation of the [Publish-subscribe pattern](https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern).
2121

22-
> publish–subscribe is a messaging pattern where senders of messages, called publishers, do not program the messages to be sent directly to specific receivers, called subscribers. Instead, published messages are characterized into classes, without knowledge of what, if any, subscribers there may be. Similarly, subscribers express interest in one or more classes, and only receive messages that are of interest, without knowledge of what, if any, publishers there are.
22+
> Publish-subscribe is a messaging pattern where senders of messages, called publishers, do not program the messages to be sent directly to specific receivers, called subscribers. Instead, published messages are characterized into classes, without knowledge of what, if any, subscribers there may be. Similarly, subscribers express interest in one or more classes, and only receive messages that are of interest, without knowledge of what, if any, publishers there are.
2323
24-
Or in simpler terms
25-
26-
> Subscribers let the publisher know they're interested, and the publisher stores their addresses so that it knows where to send which message.
24+
Or, in simpler terms
2725

26+
> Subscribers let the publisher know they're interested, and the publisher stores their addresses to know where to send which message.
2827
2928
## Mechanics
3029

31-
Depending on the features provided by a given transport there are two possible implementations of Publish-Subscribe mechanics: message-driven (persistence-based) and native.
30+
Depending on the features provided by a given transport, there are two possible implementations of Publish-Subscribe mechanics: message-driven (persistence-based) and native.
3231

3332
> [!NOTE]
34-
> For simplicity these explanations refer to specific endpoints as "Subscribers" and "Publishers". However in reality any endpoint can be both a publisher and/or and a subscriber.
35-
36-
### All subscribers gets their own copy of the event
33+
> For simplicity, these explanations refer to specific endpoints as "Subscribers" and "Publishers." However, in reality, any endpoint can be both a publisher and/or a subscriber.
3734
38-
To ensure that each subscriber can process, and potentially retry, the event independent of other subscribers, NServiceBus makes sure that each subscriber gets a copy of the published event delivered to their input queue.
35+
### All subscribers get their copy of the event
3936

37+
To ensure that each subscriber can process and potentially retry the event independently of other subscribers, NServiceBus ensures that each subscriber receives a copy of the published event delivered to their input queue.
4038

4139
### Message-driven (persistence-based)
4240

43-
Message-driven publish-subscribe is controlled by *subscribe* and *unsubscribe* system messages sent by the subscriber to the publisher. The message-driven publish-subscribe implementation is used by the [unicast transports](/transports/types.md#unicast-only-transports). These transports are limited to unicast (point-to-point) communication and have to simulate multicast delivery via a series of point-to-point communications.
44-
41+
Message-driven publish-subscribe is controlled by *subscribe* and *unsubscribe* system messages the subscriber sends to the publisher. The message-driven publish-subscribe implementation is used by the [unicast transports](/transports/types.md#unicast-only-transports). These transports are limited to unicast (point-to-point) communication and have to simulate multicast delivery via a series of point-to-point communications.
4542

4643
#### Subscribe
4744

48-
The subscribe workflow for unicast transports is as follows
45+
The subscribe workflow for unicast transports is as follows:
4946

50-
1. Subscribers request to a publisher the intent to subscribe to certain message types.
51-
1. Publisher stores both the subscriber names and the message types in the persistence.
47+
1. Subscribers request to a publisher the intent to subscribe to specific message types.
48+
1. Publisher stores the subscriber names and the message types in the persistence.
5249

5350
```mermaid
5451
sequenceDiagram
@@ -61,13 +58,11 @@ Subscriber2 ->> Publisher: Subscribe to Message1
6158
Publisher ->> Persistence: Store "Subscriber2 wants Message1"
6259
```
6360

64-
6561
The publisher's address is provided via [routing configuration](/nservicebus/messaging/routing.md).
6662

67-
6863
#### Publish
6964

70-
Message-driven publish-subscribe relies on the publisher having access to a persistent store for maintaining the mapping between message types and their subscribers.
65+
Message-driven publish-subscribe relies on the publisher's access to a persistent store to maintain the mapping between message types and their subscribers.
7166

7267
Available subscription persisters include
7368

@@ -80,9 +75,9 @@ Available subscription persisters include
8075

8176
The publish workflow for [unicast transports](/transports/types.md#unicast-only-transports) is as follows:
8277

83-
1. Some code (e.g. a saga or a handler) requests that a message be published.
84-
1. Publisher queries the storage for a list of subscribers.
85-
1. Publisher loops through the list and sends a **copy of that message** to each subscriber.
78+
1. Some code (e.g., a saga or a handler) requests that a message be published.
79+
1. The publisher queries the storage for a list of subscribers.
80+
1. The publisher loops through the list and sends each subscriber a **copy of that message**.
8681

8782
```mermaid
8883
sequenceDiagram
@@ -98,20 +93,18 @@ Publisher ->> Subscriber2: Send Message1
9893

9994
partial: disable-publishing
10095

101-
10296
### Native
10397

10498
For multicast transports that [support publish–subscribe natively](/transports/types.md#multicast-enabled-transports) neither persistence nor control message exchange is required to complete the publish-subscribe workflow.
10599

106-
107100
#### Subscribe
108101

109-
The subscribe workflow for multicast transports is as follows
102+
The subscribe workflow for multicast transports is as follows:
110103

111-
1. Subscribers send request to the broker with the intent to subscribe to certain message types.
112-
1. Broker stores the subscription information.
104+
1. Subscribers send a request to the broker with the intent to subscribe to specific message types.
105+
1. The broker stores the subscription information.
113106

114-
Note that in this case the publisher does not interact in the subscribe workflow.
107+
Note that the publisher does not interact with the subscribe workflow in this case.
115108

116109
```mermaid
117110
sequenceDiagram
@@ -124,14 +117,13 @@ Subscriber1 ->> Broker: Subscribe to Message1
124117
Subscriber2 ->> Broker: Subscribe to Message1
125118
```
126119

127-
128120
#### Publish
129121

130-
The publish workflow for multicast transports is as follows
122+
The publish workflow for multicast transports is as follows:
131123

132-
1. Some code (e.g. a saga or a handler) request that a message be published.
133-
1. Publisher sends the message to the Broker.
134-
1. Broker sends a **copy of that message** to each subscriber.
124+
1. Some code (e.g., a saga or a handler) requests that a message be published.
125+
1. The publisher sends the message to the Broker.
126+
1. The broker sends a **copy of that message** to each subscriber.
135127

136128
```mermaid
137129
sequenceDiagram

0 commit comments

Comments
 (0)