Pubsub Pattern
- Sending same message to different consumers.
- User creates new account for themselves in our website, and we have an auditing service, and a promotion service which will send an email to the newcomers.
- Producer just wants to publish the message once and then we wanna broadcast the message.
- To do this we need to use
fanoutexchange type.
- To do this we need to use
- RabbitMQ will not duplicate the message, so no need to worry about memory footprint.

[!TIP]
You do not need to declare those queues upfront. We can use what’s known as temporary queues which will be deleted automatically once the connection is closed:
queue = channel.queue_declare('', exclusive=True)
How to Start This Example
cd docs/rabbitmq.uv venv .venv.source .venv/bin/activate.uv install --requirements ./requirements.txt.- Open 3 terminal sessions and cd to the same path
- Execute the following commands now:
python src/pubsub/auditing-service.py.python src/pubsub/promotion-service.py.python src/pubsub/producer.py.