Sagas

To understand sagas and how to create one, refer to the Saga section.

Configuring Sagas

Sagas are automatically configured when ConfigureEndpoints is called, which is highly recommended. The endpoint configuration can be mostly customized using either a saga definition or by specifying the endpoint configuration inline.

To manually configure a saga on a receive endpoint, use one of the following methods.

Manually configured receive endpoints should be configured before calling ConfigureEndpoints.
services.AddMassTransit(cfg => 
{
    cfg.Using[Transport]((context, transport) => 
    {
        transport.ReceiveEndpoint("manually-configured", e =>
        {
            // configure endpoint-specific settings first
            e.SomeEndpointSetting = someValue;
            
            // configure any required middleware components next
            e.UseMessageRetry(r => r.Interval(5, 1000));
            
            // configure the saga last
            e.ConfigureSaga<MySaga>(context);
        });

        // configure any remaining consumers, sagas, etc.
        transport.ConfigureEndpoints(context);
    });
})

Configuration Methods

ConfigureSaga<T>(context);

Configures the saga on the receive endpoint.

ConfigureSaga<T>(context, saga => 
{
    // configure saga-specific middleware
});

Configures the saga on the receive endpoint and applies the additional saga configuration to the saga pipeline.

ConfigureSagas(context);

Configures all sagas that haven't been configured on the receive endpoint.