<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/the-mediator-pattern-with-masstransit-juyjfnbh0" -->

---
title: The Mediator pattern with MassTransit | daily.dev
description: MediatR's shift to a commercial license in 2025 prompted a look at MassTransit's built-in in-process mediator as a drop-in alternative for .NET developers...
canonical: https://daily.dev/posts/the-mediator-pattern-with-masstransit-juyjfnbh0
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: The Mediator pattern with MassTransit | daily.dev
og:description: MediatR's shift to a commercial license in 2025 prompted a look at MassTransit's built-in in-process mediator as a drop-in alternative for .NET developers...
og:url: https://daily.dev/posts/the-mediator-pattern-with-masstransit-juyjfnbh0
og:image: https://api.daily.dev/og/posts/JuYjfNBh0.png
og:image:alt: The Mediator pattern with MassTransit
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# The Mediator pattern with MassTransit

**[The Art of Simplicity](https://daily.dev/sources/bartwullems)** · 5 min read · 15 upvotes · 1 comments

## Summary

MediatR's shift to a commercial license in 2025 prompted a look at MassTransit's built-in in-process mediator as a drop-in alternative for .NET developers already using MassTransit. Unlike MediatR's handler-based IRequestHandler model, MassTransit's mediator is consumer-based, using the same IConsumer<T> interface as regular bus consumers, so in-process and out-of-process messaging code look identical. The piece walks through setup with AddMediator(), defining consumers and message contracts, sending commands via IMediator, handling request/response with CreateRequestClient, and using IScopedMediator when consumers need to share a DI scope. Middleware like UseMessageRetry and UseInMemoryOutbox still works, though routing slip activities are not supported through the mediator. A note flags that MassTransit itself moved to a commercial license starting from version 9.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://bartwullems.blogspot.com/2026/09/the-mediator-pattern-with-masstransit.html>

## Questions this post answers

### Can I use MassTransit instead of MediatR for the mediator pattern in .NET?

Yes, MassTransit ships with its own in-memory mediator implementation built on the same consumer model used for its message bus, so no extra package or license is needed if MassTransit is already part of the stack. It is consumer-based, using IConsumer<T> instead of MediatR's IRequestHandler<TRequest, TResponse>, and supports both fire-and-forget sends and request/response via CreateRequestClient.

_Teams weighing MediatR against MassTransit's mediator can track library licensing shifts like this on daily.dev._

### Why did teams start looking for MediatR alternatives in .NET?

MediatR moved to a commercial license in 2025, ending its status as a free default choice for implementing the mediator pattern in .NET projects. This prompted developers to reconsider whether a second in-process messaging library was even necessary, especially for teams that already depend on MassTransit, which offers equivalent mediator functionality out of the box.

_Developers reassessing dependencies after licensing changes can follow these shifts on daily.dev._

### How do I share a DbContext across multiple consumers in MassTransit's mediator pipeline?

Inject IScopedMediator instead of the default singleton IMediator when several consumers in a pipeline need to share the same dependency injection scope, such as sharing a DbContext across steps. It requires no extra configuration and becomes available automatically once AddMediator() has been called during service registration.

_Developers wiring up MassTransit pipelines can dig into scoping details like this on daily.dev._

## Community discussion

Top comments from developers on daily.dev.

**@f4nt0** · 0 upvotes

> Nice article! we still use MediatR in the projects, we keep them because it help us not spent time redoing what is already working (but this is the vision of big companies not for POC projects)

## Similar posts on daily.dev

- [Microservices Communication with RabbitMQ and .NET Core](https://daily.dev/posts/microservices-communication-with-rabbitmq-and-net-core-4blvinuyn) · C\# Corner · 0 upvotes · 0 comments
- [Implementing the Inbox Pattern for Reliable Message Consumption](https://daily.dev/posts/implementing-the-inbox-pattern-for-reliable-message-consumption-m3ouh8oxb) · Milan Jovanović · 15 upvotes · 0 comments

---

Tags: [#.net](https://daily.dev/tags/.net)

[View this post on daily.dev](https://daily.dev/posts/the-mediator-pattern-with-masstransit-juyjfnbh0)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"The Mediator pattern with MassTransit","url":"https://daily.dev/posts/the-mediator-pattern-with-masstransit-juyjfnbh0","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/the-mediator-pattern-with-masstransit-juyjfnbh0"},"datePublished":"2026-09-15T05:56:16.466Z","dateModified":"2026-09-15T05:56:41.853Z","description":"MediatR's shift to a commercial license in 2025 prompted a look at MassTransit's built-in in-process mediator as a drop-in alternative for .NET developers...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/2a264d816c5377c29b9577d8b2f52abf?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/2a264d816c5377c29b9577d8b2f52abf?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"The Art of Simplicity","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"The Art of Simplicity","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/52b68c70636d44f0901ae7cd107c9438","url":"https://daily.dev/sources/bartwullems"},"commentCount":1,"discussionUrl":"https://daily.dev/posts/the-mediator-pattern-with-masstransit-juyjfnbh0","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":15},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"keywords":".net","timeRequired":"PT5M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"The Art of Simplicity","item":"https://daily.dev/sources/bartwullems"},{"@type":"ListItem","position":3,"name":"The Mediator pattern with MassTransit"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/the-mediator-pattern-with-masstransit-juyjfnbh0","comment":[{"@type":"Comment","text":"Nice article! we still use MediatR in the projects, we keep them because it help us not spent time redoing what is already working (but this is the vision of big companies not for POC projects)","datePublished":"2026-09-20T23:12:37.760Z","url":"https://daily.dev/posts/JuYjfNBh0#c-SsQ985fkR","author":{"@type":"Person","name":"Gabriel Stundner","url":"https://daily.dev/f4nt0","image":"https://media.daily.dev/image/upload/s--UpSzkOxs--/f_auto/v1753488097/avatars/avatar_whNNg0ajcmne1B7hPHb0U?_a=BAMClqZW0"}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/the-mediator-pattern-with-masstransit-juyjfnbh0#faq","mainEntity":[{"@type":"Question","name":"Can I use MassTransit instead of MediatR for the mediator pattern in .NET?","acceptedAnswer":{"@type":"Answer","text":"Yes, MassTransit ships with its own in-memory mediator implementation built on the same consumer model used for its message bus, so no extra package or license is needed if MassTransit is already part of the stack. It is consumer-based, using IConsumer\u003cT\u003e instead of MediatR's IRequestHandler\u003cTRequest, TResponse\u003e, and supports both fire-and-forget sends and request/response via CreateRequestClient. Teams weighing MediatR against MassTransit's mediator can track library licensing shifts like this on daily.dev."}},{"@type":"Question","name":"Why did teams start looking for MediatR alternatives in .NET?","acceptedAnswer":{"@type":"Answer","text":"MediatR moved to a commercial license in 2025, ending its status as a free default choice for implementing the mediator pattern in .NET projects. This prompted developers to reconsider whether a second in-process messaging library was even necessary, especially for teams that already depend on MassTransit, which offers equivalent mediator functionality out of the box. Developers reassessing dependencies after licensing changes can follow these shifts on daily.dev."}},{"@type":"Question","name":"How do I share a DbContext across multiple consumers in MassTransit's mediator pipeline?","acceptedAnswer":{"@type":"Answer","text":"Inject IScopedMediator instead of the default singleton IMediator when several consumers in a pipeline need to share the same dependency injection scope, such as sharing a DbContext across steps. It requires no extra configuration and becomes available automatically once AddMediator() has been called during service registration. Developers wiring up MassTransit pipelines can dig into scoping details like this on daily.dev."}}]}
```

