Class MessagingServiceCollectionExtensions
- Namespace
- Microsoft.Extensions.DependencyInjection
- Assembly
- Stratara.Outbox.RabbitMQ.dll
Service-collection extensions for the Stratara messaging stack.
public static class MessagingServiceCollectionExtensions
- Inheritance
-
MessagingServiceCollectionExtensions
- Inherited Members
Methods
AddMessaging(IHostApplicationBuilder)
Registers the messaging infrastructure: IMessageBus backed by
Stratara.Outbox.RabbitMQ.Messaging.RabbitMqBus, the IMessagingIdentifier service, and binds
MessagingOptions from the Messaging configuration section,
BusEnvelopeJsonOptions from BusEnvelopeJson and
MessageRetryOptions from MessageRetry, the retry bounds and the prefetch bound validated
at start-up so that a bound of zero is refused before a message is consumed. When the host stops, it waits —
within the host's shutdown timeout — for the subscriptions that stopped with it to let their running handlers
settle, before anything is disposed.
public static IHostApplicationBuilder AddMessaging(this IHostApplicationBuilder builder)
Parameters
builderIHostApplicationBuilderThe host-application builder.
Returns
- IHostApplicationBuilder
The same builder, for chaining.
Examples
Bind the RabbitMQ bus from configuration. The composite worker DI extensions
(AddBackendServices, AddCommandWorkerServices, …) already call
this internally; only call it directly when composing a custom worker shape.
// appsettings.json:
// "Messaging": { "Host": "rabbitmq", "VirtualHost": "/", "Username": "...", "Password": "..." }
var builder = Host.CreateApplicationBuilder(args);
builder.AddMessaging();