Topics
A Pub/Sub topic hands every message to each subscription attached to it, and the subscribers of one subscription share its messages.
The diagram as text
- Subscription billing: Subscriber 1: messages 1 and 3; Subscriber 2: message 2
- Subscription audit: One subscriber: messages 1, 2, 3
- Publisher → Topic orders: publishes
- Topic orders → Subscription billing: every message
- Topic orders → Subscription audit: every message
- A subscription keeps a message until it is acknowledged or its retention runs out, with or without a subscriber
A publisher names a topic and nothing else. A subscription is a resource of its own, attached to exactly one topic. A topic may have many subscriptions.
A subscription receives the messages published to its topic after it was created. Each subscription gets its own copy of every message, so billing and audit never take messages from each other.
The subscribers of one subscription share its messages: each gets a part, and no two get the same part. Adding a subscriber to a subscription spreads its load. Adding a subscription adds a reader of everything.
In ruststream-gcp-pubsub, a handler names the subscription it reads, through
GooglePubSub or a bare name, and a publisher names the
topic it writes to. The model is Google's
(subscription overview,
Pub/Sub basics). How a subscriber
holds a message while it works is on Leases.