Monday, August 6, 2018

MassTransit, a real alternative to NServiceBus?


So I was trying to find an free and open-source alternative to NServiceBus and turns out that I found MassTransit. Let's take a look at MassTransit.

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

Their GitHub repo has many interesting samples including:

Conclusion

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.

At the moment, I cannot recommend MassTransit simply because I haven't used it in production yet. However, I like what I know so far. That said, I plan to continue reviewing MassTransit and will soon share some insights on this blog and on my github page so keep posted.

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

See Also

Why you should start using .Net Core
Package Management in .Net Core
Exporting Html to Pdf using only JavaScript
Importing CSVs with .Net Core and C#
Exporting a CSV generated in-memory in Asp.Net with C#
Building and Running Asp.Net Core apps on Linux
Asp.Net / Asp.Net Core: Generating views in the backend

For more posts on .Net Core, please click here.

References

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