A project example using RabbitMQ and .Net Core 6 (console).
RabbitMQ is an open source message broker software. It accepts messages from producers, and delivers them to consumers. It acts like a middleman which can be used to reduce loads and delivery times taken by web application servers.
I recommend you visit the project website and even the tutorials page.
This project consists of three sub-projects, which are:
- RabbitMQNetCore: a class project containing a class to type our message and also classes with the rules for sending and consuming the message.
- RabbitMQNetCore.Publisher: a console project responsible for running the publisher.
- RabbitMQNetCore.Consumer: a console project responsible for running the consumer.
Could I have created a single project, yes I could, but I wanted to separate it for a better understanding of what each one does.
First we need to run the RabbitMQ service, I recommend that you make use of a Docker image, so you need to have Docker installed and run the following command:
docker run -d --hostname localhost --name localrabbit -e RABBITMQ_DEFAULT_USER=user -e RABBITMQ_DEFAULT_PASS=password rabbitmq:3-management
This command will create and run an instance of RabbitMQ.
Run the Publisher project:
dotnet run --project .\RabbitMQNetCore.Publisher\RabbitMQNetCore.Publisher.csproj
Run the Consumer project:
dotnet run --project .\RabbitMQNetCore.Consumer\RabbitMQNetCore.Consumer.csproj
Now, in the Publisher console, you can perform tests by sending messages and monitoring the consumption of the same in the Consumer console.
This is a simple project to demonstrate how the messaging service works.
This project is MIT Licensed.
Hello everyone, my name is Diego Anzolin Ferreira. I'm a .NET developer from Brazil. I hope you will enjoy this project as much as I enjoy developing it. If you have any problems, you can post a GitHub issue. You can reach me out at diego@anzolin.com.br.
Want to help me keep creating open source projects, make a donation:
Thank you!