Publish and subscribe places a topic between producers and consumers. The publisher does not need to know its listeners, and several subscribers can receive the same event. Unlike a work queue that assigns one task to one worker, each subscriber reacts to the event.
Changing the topic in the demo changes the recipient set. Delivery guarantees, duplicates, and replay for late subscribers depend on the broker.
When to use
Use it when one event must reach independent capabilities such as notifications and analytics.