# Samples

Working code is an excellent way to learn how to use MassTransit features. The samples below show the capabilities of MassTransit, and can be cloned, forked, and explored to get a better understanding.

The new samples are standalone repositories, which use NuGet to pull dependencies exactly as a developerwould use MassTransit.

# Getting Started

This project is part of the MassTransit documentation (opens new window). Refer to that link for details.

If you're new to MassTransit, start with this sample to understand how MassTransit works

Clone the sample: GitHub Repository (opens new window)

# Sample Twitch

This sample was created along with the Twitch/YouTube video series.

Clone the sample: GitHub Repository (opens new window)

# Sample Library

This sample was created along with Season 2 of the Twitch/YouTube video series.

Clone the sample: GitHub Repository (opens new window)

# Sample ForkJoint

This sample was created along with Season 3 of the Twitch/YouTube video series.

Fork Joint is a fictional restaurant built during Season 3 of the MassTransit Live Code Video Series. You can watch the episodes on YouTube (opens new window) and follow along by resetting to the various commits in the Git history.

Clone the sample: GitHub Repository (opens new window)

# Trashlantis

This sample was created to show how the in-memory outbox is used and ensures message delivery in the presence of transaction failures.

Clone the sample: GitHub Repository (opens new window)

# Node (MassTransit in TypeScript)

This sample uses MassTransit (for .NET) combined with the MassTransit (for JavaScript) NPM package (opens new window) to send requests from a node application and handle the subsequent response from a MassTransit Consumer (running in .NET). The services communicate via RabbitMQ (included in the docker-compose.yml file).

Clone the sample: GitHub Repository (opens new window)

# Scoped Filters

.NET 5, ASP.NET

This sample uses an HTTP header named Token to pass credentials to an API Controller. That header is read into a scoped type (Token) using an action filter as part of the API request. The action method then uses the MassTransit request client to send a request to a consumer. Scoped message filters are configured for publish, send, and consume to transfer the header value (via the Token object in the container scope) to outbound messages, and then on the consumer side extract that MassTransit message header back into the Token type in the consumer scope.

Clone the sample: GitHub Repository (opens new window)

# Azure Functions

Shows how to use MassTransit with Azure Functions (v3).

Clone the sample: GitHub Repository (opens new window)

# Job Consumers

Shows how to use the job consumers with Entity Framework Core.

Features used:

  • Job Consumers
  • Entity Framework Core

Clone the sample: GitHub Repository (opens new window)

# Batch Processing using Sagas

Shows how to perform batch processing and tracking using sagas.

Clone the sample: GitHub Repository (opens new window)

# SignalR

This sample will show a variety of built in tools and techniques in MassTransit.

Clone the sample: GitHub Repository (opens new window)

# Request Response

This sample demonstrates how to create a client that sends a request to a service which responds with a response.

Features used:

  • Request Client

Clone the sample: GitHub Repository (opens new window)

# Shopping Cart

This was a fun sample, created in response to a blog post (opens new window) on how to send an email to a customer that abandoned a shopping cart. My response to that post is located here (opens new window).

Features used:

  • Automatonymous
  • Quartz

Clone the sample: GitHub Repository (opens new window)

# Courier

Courier is MassTransit's routing-slip implementation, which makes it possible to orchestrate distributed services into a business transaction. This sample demonstrates how to create and execute a routing slip, record routing slip events, and track transaction state using Automatonymous (opens new window).

This sample includes multiple console applications, which can be started simultaneously, to observe how the services interact.

Features used:

  • Courier
  • Automatonymous

Clone the sample: GitHub Repository (opens new window)

# Race Registration

This sample has multiple console applications, and a web API, allowing registrations to be submitted. The routing slip is tracked using a saga, and can compensate when an activity faults.

Features used:

  • Courier
  • Automatonymous

Clone the sample: GitHub Repository (opens new window)

# Container

MassTransit supports several dependency injection containers. Examples of how to setup and use MassTransit with those containers is provided via a sample application.

Only currently active containers are fully supported. Other containers are still supported, but considered legacy.

Features used:

  • Autofac
  • Castle Windsor
  • StructureMap
  • Lamar
  • Simple Injector
  • Microsoft Extensions Dependency Injection

Clone the sample: GitHub Repository (opens new window)

# Quartz

Features used:

  • Scheduling
  • Quartz

Clone the sample: GitHub Repository (opens new window)

# Hangfire

Features used:

  • Scheduling
  • Hangfire

Clone the sample: GitHub Repository (opens new window)

# Application Insights

Clone the sample: GitHub Repository (opens new window)

# RabbitMQ Direct Exchange

Shows how to configure a consumer and a producer to use RabbitMQ direct exchange routing.

Features used:

  • RabbitMQ

Clone the sample: GitHub Repository (opens new window)

# Benchmark

Test the performance of MassTransit in your environment.

Clone the sample: GitHub Repository (opens new window)

# RabbitMQ MQTT Consumer

Utilise RabbitMQ as a MQTT server and consume IOT data.

Clone the sample: GitHub Repository (opens new window)