Concurrency Limit Configuration
The concurrency limit filter supports any pipe context (any type that implements PipeContext, which includes most *Context types in MassTransit). For this
reason alone the filter still exists in MassTransit despite being deprecated in concurrent message limit scenarios.
Configure a concurrency limit
Section titled “Configure a concurrency limit”The recommended approach is to use ConcurrentMessageLimit at the appropriate level.
On the bus
Section titled “On the bus”services.AddMassTransit(x =>{ x.UsingRabbitMq((context, cfg) => { cfg.Host("localhost");
cfg.ConcurrentMessageLimit = 8;
cfg.ConfigureEndpoints(context); });});On a receive endpoint
Section titled “On a receive endpoint”cfg.ReceiveEndpoint("input-queue", e =>{ e.ConcurrentMessageLimit = 4;
e.ConfigureConsumer<MyConsumer>(context);});In a consumer definition
Section titled “In a consumer definition”services.AddMassTransit(x =>{ x.AddConsumer<MyConsumer, MyConsumerDefinition>();
x.UsingRabbitMq((context, cfg) => { cfg.ConfigureEndpoints(context); });});
public class MyConsumerDefinition : ConsumerDefinition<MyConsumer>{ protected override void ConfigureConsumer(IReceiveEndpointConfigurator endpointConfigurator, IConsumerConfigurator<MyConsumer> consumerConfigurator) { endpointConfigurator.ConcurrentMessageLimit = 4; }}Using the deprecated filter
Section titled “Using the deprecated filter”If you still need to use the concurrency limit filter (for example, for non-standard scenarios):
cfg.ReceiveEndpoint("submit-order", e =>{ e.UseConcurrencyLimit(4);
e.ConfigureConsumer<SubmitOrderConsumer>(context);});The filter supports any pipe context, making it useful for scenarios beyond message consumption, such as limiting concurrency in send or publish pipelines.