| Service | Pulls | Size | Version |
|---|---|---|---|
| API | |||
| User API | |||
| Web (Portal) | |||
| Invalidator |
MessageBus is a lightweight RabbitMQ-powered message pipeline focused on event-driven cache invalidation in .NET applications.
It provides a clean pattern for publishing events from APIs after completing database updates, and processing those events asynchronously using independent worker services that connect to Dragonfly/Redis.
This approach keeps APIs fast and responsive while ensuring cache consistency across services.
The workerβs responsibility is only to remove stale keys. Any pre-warm logic (such as regenerating and repopulating cache values) remains inside the web application and will execute naturally on the next access after invalidation.
A single role update can affect hundreds of users β so distributed cache invalidation is essential for consistent authorization.
A minimal IEventBus interface with a RabbitMQ implementation supporting:
durable exchanges
routing keys
persistent messages
JSON serialization
A background worker that listens to specific events and:
receives an event from RabbitMQ
invalidates related keys in Redis/Dragonfly
(optionally) logs the invalidation action
The worker runs independently and never blocks the API.
A standard flow:
API completes database update
API publishes a cache-related event
RabbitMQ routes the event to a queue
Cache worker consumes the event
Worker removes the relevant keys in Redis
Open RabbitMQ Management Dashboard:
(default credentials: rabbit / rabbit)
# Clone the repository
git clone https://github.com/hasanjaved-developer/message-hub.git
cd message-hub
# Start the observability stack
docker compose -f docker-compose.yml up -dThis project is licensed under the MIT License.



