Monday, August 6, 2018

MassTransit, a real alternative to NServiceBus?


Looking for an free and open-source alternative to NServiceBus? Maybe MassTransit could be what you are looking for.

What is MassTransit?

MassTransit is a lightweight service bus for building distributed .NET applications. The main goal is to provide a consistent, .NET friendly abstraction over the message transport (RabbitMQ, Azure Service Bus, etc.).

MassTransit is not a new project. They've been around since 2007 and were created as an alternative to NServiceBus. In early 2014, the framework was rewritten to support asynchronous programming as well as leveraged the power of advanced messaging platforms like RabbitMQ that since then, became the default broker. The remaining code was also rewritten, resulting in an entirely new, completely asynchronous, and highly optimized framework for message processing.

Benefits

Like NServiceBus, MassTransit helps decoupling your backend from your frontend (and in general, decoupling services), leveraging enterprise design patterns like CQRS and Eventual Consistency.

MassTransit benefits include:
  • providing support for messages, sagas
  • supporting different transports
  • allows automated or custom retries on failures
  • poison message handling
  • exception management
  • custom serialization
  • message correlation
  • routing
  • scheduling
  • and more...

MassTransit is also extremely customizable and can run (as of July 2018) on RabbitMQ and Azure Service Bus which is an enormous benefits as both are strong and stable platforms with different characteristics. It also supports the new .Net Standard 2.0 on the new .net core framework, transforming it in truly multi-platform framework.

Sample Code

I also have tested it in different scenarios with very positive results. Here are some of my experiences

Their GitHub repo has many interesting samples including:

Final Thoughts

I've been using NServiceBus for quite some time. While I like it and recognize the value it adds, I miss open alternatives to it in the .NET ecosystem. MassTransit appears to be a very robust and mature framework and I'm excited to try it out in production.

And you, have any experience with this framework? Let us know!

See Also


Why you should start using .Net Core
Building and Running Asp.Net Core apps on Linux
.NET Core and .NET merging as .NET 5.0

References

MassTransit - Project
MassTransit - GitHub
MassTransit - Nuget.org
Ben Morris: Comparing nServiceBus and MassTransit: Do we still need .Net integration frameworks?