Do you use MassTransit to build reliable distributed applications?
Updated by Daniel Mackay [SSW] 1 year ago. See history
.NET Messaging Libraries
There are several .NET messaging libraries that all abstract the underlying transport. These include:
- MassTransit (recommended)
There are also the service bus specific libraries:
- Azure Service Bus(not recommended)
- Amazon SQS(not recommended)
- RabbitMQ(not recommended)
- (and more)
Advantages of using MassTransit
✅ Open-source and free to use
✅ Enables swapping of messaging transports by providing a common abstraction layer
✅ Supports multiple messaging concepts:
- Point-to-Point
- Publish/Subscribe
- Request/Response
✅ Supports multiple messaging transports:
- In-Memory
- RabbitMQ
- Azure Service Bus
- Amazon SQS
- ActiveMQ
- Kafka
- gRPC
- SQL/DB
✅ Supports complex messaging patterns such as Sagas
Scenarios
Scenario 1 - Modular Monolith
A Modular Monolith architecture requires all modules to be running in a single process. MassTransit can be used to facilitate in-memory communication between modules in the same process.
This allows us to send events between modules and also request data from other modules.
Scenario 2 - Azure Hosted Microservices
When building microservices in Azure, it's common to use Azure Service Bus as the messaging transport. With minimal changes, MassTransit can be used to send messages to and from Azure Service Bus instead of using the In-Memory transport.
Scenario 3 - Locally Developing Microservices
When developing microservices locally, it's common to use containers for each service. However, some of the cloud based messaging services (e.g. Azure Service Bus) are not able to be run in a container locally. In this scenario, we can easily switch from using the Azure Service Bus transport to Containerized RabbitMQ transport
Demo Code
If you're interested in seeing MassTransit in action, check out github.com/danielmackay/dotnet-mass-transit
Categories
Need help?
SSW Consulting has over 30 years of experience developing awesome software solutions.