Skip to content

changhuixu/rabbitmq-labs

Repository files navigation

RabbitMQ Tutorials

This is the code repository for the demos described in my Medium articles.

Medium Articles

In this article, we will talk about how to quickly spin up RabbitMQ instances on Docker. We will go through two ways to run a RabbitMQ Docker image in a container: (1) using the docker run command; (2) using Docker Compose. Getting familiar with these two approaches should greatly accelerate your learning on RabbitMQ.

This blog covers demos 01 and 02.

How to implement an asynchronous RabbitMQ consumer as an ASP.NET Core hosted service, and how to run the consumer in a Docker container.

Publish RabbitMQ messages in an ASP.NET Core Web API project, consume messages using a worker service, and run a multi-container application with Docker Compose.

Demos

A basic pub/sub model with one message producer and two consumers. Exchange type: fanout. This demo shows how to use a exclusive queue to produce and consume messages.

A basic queue based on route key. Exchange type: topic. This demo shows how to use a passive queue to produce and consume messages, as well as how to pass some basic properties along with the messages, thus consumers can verify those properties.

Some user accounts are set up and a definition file can be easily loaded to the RabbitMQ service using a docker-compose command.

Consuming RabbitMQ messages using an ASP.NET Core Worker Service. This project implements async operations for the Received event.

This demo also includes an example docker-compose.yml for the worker service and rabbitmq services.

This demo includes a Web API project as the message publisher, and a Worker Service project as the message consumer. The API project and Worker Service project are connected by a RabbitMQ service. The docker-compose.yml orchestra these services in containers.

This demo includes all services in demo 04, and adds an audit queue service, plus a MongoDB database to persist messages.