52

What is the benefit of building on top of MassTransit compared to building directly on top of RabbitMQ?

I believe one benefit provided by MassTransit is 'type' exchange (publish subscribe by interface / type) so the content of the message is structured, compared to plain RabbitMQ exchanges where the content of the message is unstructured text / blob.

What other benefits provided by MassTransit?

Endy Tjahjono
  • 24,120
  • 23
  • 83
  • 123

1 Answers1

78

Things that MT adds on top of just using RabbitMQ:

  • Optimized, asynchronous multithreaded, concurrent consumers
  • Message serialization, with support for interfaces, classes, and records, including guidance on versioning message contracts
  • Automatic exchange bindings, publish conventions
  • Saga state machines, including persistent state via Entity Framework Core, MongoDB, Redis, etc.
  • Built-in metrics, Open Telemetry, Prometheus
  • Message headers
  • Fault handling, message retry, message redelivery

Those are just a few, some more significant than others. The fact that the bus hosts your consumers, handlers, sagas, and manages all of the threading is probably the biggest advantage, and the fact that you can host multiple buses in the same process.

Serialization is the next biggest benefit, since that can be painful to figure out, and getting an interface-based message contract with automatic deserialized into types (including dynamically-backed interface types) is huge. Publishing a single class that implements multiple interfaces, and seeing all interested consumers pick up their piece of the message asynchronously is just awesome in production as new interfaces can be added to producers and down-level consumers are unaffected.

Those are a few, you can check out the documentation for more information, or give the really old .NET Rocks! podcast a listen for some related content by yours truly.

UPDATE: There is an entire series on YouTube covering MassTransit now.

Chris Patterson
  • 28,659
  • 3
  • 47
  • 59
  • 12
    The abstraction is also nice. We use Azure Service Buses in the cloud and RabbitMQ when deploying on customer premises without any significant code changes. – David Pfeffer Sep 07 '12 at 12:55
  • 1
    Thanks for such an articulate explanation suitable for business. Switching between GRPC to a SB is liberating, contracts all in C# is great, learning one pattern, great, speed of delivery great. It's just a facade but it delivers so much. Programming by Contract is old, but this makes it easy. – Doug Thompson - DouggyFresh Sep 23 '22 at 17:42