Class MediatorWorkerServiceCollectionExtensions
- Namespace
- Microsoft.Extensions.DependencyInjection
- Assembly
- Stratara.Outbox.RabbitMQ.dll
Service-collection extensions for the Stratara mediator-command worker.
public static class MediatorWorkerServiceCollectionExtensions
- Inheritance
-
MediatorWorkerServiceCollectionExtensions
- Inherited Members
Methods
AddHeavyCommandWorker(IServiceCollection, int?)
Registers a dedicated heavy-command Stratara.Outbox.RabbitMQ.Mediator.MediatorCommandWorker lane as a hosted service. It drains the heavy-command topic/subscription (the lane that commands marked IHeavyCommand are dispatched to), keeping the interactive lane permanently free. Run it in the same host as AddMediatorWorker(IServiceCollection) (two lanes, one process) or in a dedicated, independently scaled heavy-command host.
public static IServiceCollection AddHeavyCommandWorker(this IServiceCollection services, int? degreeOfParallelism = null)
Parameters
servicesIServiceCollectionThe DI container.
degreeOfParallelismint?The number of concurrent subscriptions this lane opens; null defaults to ProcessorCount. Cap it low (e.g. 1–2) to bound the resources long-running commands can consume.
Returns
- IServiceCollection
The same service collection, for chaining.
Examples
Drains the HeavyCommand topic — heavy-command / heavy-command-subscription
unless Messaging:Topics renames it. Run it alongside the interactive worker, or in a host
of its own that scales separately:
services.AddMediatorWorker();
services.AddHeavyCommandWorker(degreeOfParallelism: 2);
AddMediatorWorker(IServiceCollection)
Registers the interactive Stratara.Outbox.RabbitMQ.Mediator.MediatorCommandWorker as a hosted service. The worker
subscribes to the configured command topic, deserializes incoming CommandEnvelopes,
restores the session context, and dispatches them through IMediator. Commands marked
IHeavyCommand are routed to a separate topic and
are NOT drained by this lane — run AddHeavyCommandWorker(IServiceCollection, int?) to process them.
public static IServiceCollection AddMediatorWorker(this IServiceCollection services)
Parameters
servicesIServiceCollectionThe DI container.
Returns
- IServiceCollection
The same service collection, for chaining.
Examples
The worker consumes the topic named Command in the Messaging:Topics section,
defaulting to command / command-subscription:
builder.AddMessaging();
builder.Services.AddMediatorWorker();