# 8.0.0

MassTransit v8 is the first major release since the availability of .NET 6. MassTransit v8 works a significant portion of the underlying components into a more manageable solution structure. Focused on the developer experience, while maintaining compatibility with previous versions, this release brings together the entire MassTransit stack.

Automatonymous, Green Pipes, and NewId have been completely integrated into a single MassTransit solution. This means that every aspect of MassTransit is now within a single namespace, which makes it easy to find the right interface, extension, and whatever else is needed. A lot of common questions result in a missing using statement, and now that should no longer be the case. The entire developer surface area, for the most part, exists within the MassTransit namespace.

# Upgrading

When upgrading from previous versions of MassTransit, there are a few initial steps to get up and running. While this list doesn't cover everything, these are the main items experienced so far when upgrading from a previous version.

  • Remove any references to packages that were not updated with v8. This includes:
    • GreenPipes
    • NewId
    • Automatonymous
    • MassTransit.AspNetCore
    • MassTransit.Extensions.DependencyInjection
    • Any of the third-party container assemblies.
  • Remove any using statements that for namespaces that no longer exist

# Serialization

The default JSON serializer is now System.Text.Json. Refer to Microsoft's Migration Guide (opens new window) if you encounter any serialization issues after upgrading.

To continue using Newtonsoft for serialization, add the MassTransit.Newtonsoft package and specify one of the configuration methods when configuring the bus:

  • UseNewtonsoftJsonSerializer
  • UseNewtonsoftRawJsonSerializer
  • UseXmlSerializer
  • UseBsonSerializer

# Hosted Service

Previous versions of MassTransit required the use of the MassTransit.AspNetCore package to support registration of MassTransit's hosted service. This package is no longer required, and MassTransit will automatically add an IHostedService for MassTransit.

The host can be configured using IOptions configuration support, such as shown below:

services.ConfigureOptions<MassTransitHostOptions>(options =>
{
    options.WaitUntilStarted = true;
    options.StartTimeout = TimeSpan.FromSeconds(30);
    options.StopTimeout = TimeSpan.FromMinutes(1);
});

# Third-Party Container Support

MassTransit is now using Microsoft.Extensions.DependencyInjection.Abstractions as an integral configuration component. This means that all configuration (such as AddMassTransit, AddMediator) is built against IServiceCollection. Support for other containers is provided using each specific container's extensions to work with IServiceCollection and IServiceProvider.

For example, using Autofac, the configuration might look something like what is shown below.

var collection = new ServiceCollection();

collection.AddMassTransit(x =>
{
    x.AddConsumer<SubmitOrderConsumer>();

    x.UsingRabbitMq((context, cfg) => 
    {
        cfg.ConfigureEndpoints(context);
    });
});
var factory = new AutofacServiceProviderFactory();
var container = factory.CreateBuilder(collection);

return factory.CreateServiceProvider(container);

MassTransit would then be able to use IServiceProvider with Autofac to create scopes, resolve dependencies, etc.

# Observers

Observers registered in the container will be connected to the bus automatically, including:

  • IBusObserver