SAIF.NCore.Messaging exposes three IServiceCollection extension methods that
work in any hosting context: AddSaifMessaging registers the message bus
client, serializer, publisher, and handler dispatcher; AddSaifMessagingOutbox
adds the transactional outbox store and a background dispatcher for worker and
API hosts; and AddMessageHandler<TMessage, THandler> registers one message
handler. A consuming application must call AddSaifMessaging first, register
its own handlers, and supply an IEnvironmentClient and an
IOutboxConnectionFactory because the library resolves both but never
registers them.
configuration is the application's root configuration; its Messaging section is bound to MessagingOptions. Must be called before AddSaifMessagingOutbox and AddMessageHandler.
configuration is the application's root configuration; its Messaging:Outbox section is bound to OutboxOptions. Skips the hosted dispatcher when the SAIF_MESSAGING_DISABLE_DISPATCH environment variable is true.
No parameters. THandler must implement IMessageHandler<TMessage>. Each call adds one handler; every handler registered for a message type is invoked for that type.
Properties a consumer overrides, and environment variables a base class reads, that change registration or middleware behavior. Environment variables are also listed in Configuration.
Name
Kind
Default
Effect
Source
SAIF_MESSAGING_DISABLE_DISPATCH
Environment variable (process)
Unset, treated as false
When true, AddSaifMessagingOutbox does not register OutboxDispatchService. Outbox rows are still written by MessagePublisher but this process never dispatches them.
Waits Messaging:Outbox:PollIntervalSeconds between cycles using a PeriodicTimer. Each cycle creates a service scope, reads up to Messaging:Outbox:BatchSize pending rows from IOutboxStore, sends them through IMessageBusClient, and marks them dispatched. A failed cycle is logged and the loop continues on the next tick. The stopping token is passed to the store and bus calls, so an in-flight batch is abandoned on shutdown and its rows stay pending.
Note: Statements marked with † are derived from dependency library
documentation via the Legends CLI. They describe inherited behavior from the
indicated origin library and should be verified if the dependency version changes.