Skip to content

Class WolverineSetupExtensions

Namespace: Momentum.ServiceDefaults.Messaging.Wolverine
Assembly: Momentum.ServiceDefaults.dll

Provides extension methods for configuring Wolverine messaging framework.

csharp
[ExcludeFromCodeCoverage]
public static class WolverineSetupExtensions

Inheritance

objectWolverineSetupExtensions

Inherited Members

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Fields

SectionName

csharp
public const string SectionName = "Wolverine"

Field Value

string

Methods

AddWolverineWithDefaults(IServiceCollection, IConfiguration, Action<WolverineOptions>?)

Adds Wolverine services with comprehensive defaults for enterprise messaging scenarios.

csharp
public static void AddWolverineWithDefaults(this IServiceCollection services, IConfiguration configuration, Action<WolverineOptions>? configure)

Parameters

services IServiceCollection

The service collection to configure.

configuration IConfiguration

The application configuration containing connection strings and messaging settings.

configure Action<WolverineOptions>?

Optional action to customize Wolverine options for specific business requirements.

Remarks

This method provides a complete messaging infrastructure configuration including:

Persistence and Reliability:

  • PostgreSQL persistence for message durability (inbox/outbox patterns)
  • Automatic transaction scoping for Wolverine-integrated persistence operations
  • Default retry policy for transient database/timeout failures, then dead letter queue

Important: message persistence (inbox/outbox) and the PostgreSQL queue transport share the database behind the ServiceBus connection string — Wolverine does not support splitting them. Point ServiceBus at the application database (the template default) so the outbox lives beside the business data in its own schema; pointing it at a separate database reopens a crash window between the business commit and the outbox persist in which outgoing messages can be lost.

Integration and Transport:

  • Kafka integration for high-throughput event streaming
  • CloudEvents standard support for interoperability
  • System.Text.Json serialization with performance optimization
  • Cross-service message routing and topic management

Quality and Observability:

  • FluentValidation integration for automatic message validation
  • Structured exception handling with retry policies
  • OpenTelemetry instrumentation for distributed tracing
  • Performance monitoring and request tracking middleware
  • Health checks for messaging infrastructure components

Development and Deployment:

  • Resource setup on startup for database migrations
  • Convention-based handler discovery from domain assemblies
  • Environment-aware configuration and feature flags

ConfigureAppHandlers(WolverineOptions, Assembly?)

Configures Wolverine to discover and register message handlers from domain assemblies.

csharp
public static WolverineOptions ConfigureAppHandlers(this WolverineOptions options, Assembly? applicationAssembly = null)

Parameters

options WolverineOptions

The Wolverine options to configure.

applicationAssembly Assembly?

Optional application assembly. If null, uses the entry assembly.

Returns

WolverineOptions

The configured Wolverine options for method chaining.

Remarks

Discovers handlers from all assemblies marked with .

ConfigureReliableMessaging(WolverineOptions)

Configures Wolverine for reliable message delivery.

csharp
public static WolverineOptions ConfigureReliableMessaging(this WolverineOptions options)

Parameters

options WolverineOptions

Returns

WolverineOptions

Remarks

Enables:

  • Automatic transaction middleware
  • Durable local queues for reliable processing
  • Durable outbox pattern on all sending endpoints
  • Durable inbox on all listening endpoints — incoming messages (e.g. from Kafka) are persisted before processing, giving at-least-once delivery with duplicate detection by message id across redeliveries
  • Transient-failure policy ( marked transient, and ): two quick in-process retries (50ms/250ms), then durable scheduled retries (5s/30s) that release the listener instead of blocking it (important for Kafka partitions), then the dead letter queue

Failure rules added by the application (via the configure callback of AddServiceBus) are evaluated before these defaults and therefore take precedence. Dead-lettered messages are stored in the Wolverine persistence schema (svcbus_*.wolverine_dead_letters) and can be inspected and replayed with the storage CLI command or IDeadLetterAdminService.