Thursday 30 May 2019

Distributed Microservice Architecture with Rabbitmq and DotNetCore

When we say distributed, suddenly 3rd parties message broker comes in our mind like Azure Service Bus or RabbitMQ. Let explore RabbitMQ and its implementation in DotnetCore.

RabbitMQ is a message broker: it accepts and forwards messages. It use AMQP Advanced Message Queuing Protocol.

Key Points:

  • Message: a package for information, usually composed of two parts; headers, containing metadata, and a body, containing a binary package containing the actual message itself
  • Producer: Whoever creates and sends a message.
  • Consumer: Whoever receives and reads a message
  • Queue: A communication channel that enqueues messages for later retrieval by one or more consumers.
  • Exchange: A queue aggregator that routes messages to queues based on some predefined logic


Run RabbitMq through docker:
docker run -d --hostname my-rabbit --name some-rabbit -p 15672:15672 -p 5672:5672 rabbitmq:3-management

Then go to http://localhost:15672 and use following credentials.
Username:guest
Password:guest

Advantage of using it?
Checkout https://www.rabbitmq.com/features.html

How it can fit in to distributed micro service architecture?
Micro soft itself described in one of his GitHub implementation. With this design.
https://github.com/dotnet-architecture/eShopOnContainers

Any simple running demo of above design by using RabbitMq.Client in DotNetCore ?
Yes, https://github.com/rajkrs/DotnetCoreWebApiAndRabbitMq

I don’t want to use RabbitMq Dotnet Client, any supplements?
EasyNetQ is more popular than other, check it out http://easynetq.com/

Any simple running demo of above design by using EasyNetQ?
Yes, https://github.com/rajkrs/EasyNetQDotNetCore