RabbitMQ
This guide shows you how to work with RabbitMQ locally using Docker Compose and Python. This lab demonstrates real-time event publishing and consumption using the pika client.
Prerequisites
Section titled “Prerequisites”- Docker installed and running.
- Dev Containers extension installed (optional).
How to execute
Section titled “How to execute”-
Setup Environment:
Open VS Code in the project folder and execute this command in the Command Palette:
Terminal window > Dev Containers: Reopen in ContainerTerminal window pip install uv && uv sync -
Start Infrastructure: Launch the RabbitMQ container:
Terminal window docker compose up -d -
Run the Example:
- Publish events (Terminal 1):
Terminal window python publish.py - Listen for events (new terminal):
Terminal window python listen.py
- Publish events (Terminal 1):
Validate results
Section titled “Validate results”Open the RabbitMQ Management UI and navigate to Queues to inspect the user_events queue (credentials from .env):
http://localhost:15672Clean Up
Section titled “Clean Up”docker compose down -v