Public .NET API ReferenceL3 Persistence & IntegrationsStableAOT: Partial

EricksonLopez.Messaging

High-performance, zero-allocation, Native AOT-first distributed messaging and pub/sub framework for .NET 10 microservices and cloud brokers.

25 namespaces95 types338 membersGenerated from XML docs & assemblies · UTC 2026-12-01

Showing 95 of 95 types (338 members)

EricksonLopez.Messaging#

1
class

MessagingHealthCheckExtensions

Assembly: EricksonLopez.Messaging
public static class MessagingHealthCheckExtensions

Provides extension methods for registering `MessagingHealthCheck` in health check services.

Members (4)

  • methodAddMessagingHealthCheck
    public static IServiceCollection AddMessagingHealthCheck(this IServiceCollection services)

    Registers a transient `MessagingHealthCheck` in the service collection.

    services: this IServiceCollection
    The service collection to configure.

    Returns: The configured `IServiceCollection`.

    Exceptions: ArgumentNullException: `services` is `null`

  • methodAddMessagingHealthCheck
    public static IServiceCollection AddMessagingHealthCheck(this IServiceCollection services, Action<MessagingHealthCheckOptions>? configureOptions)

    Registers a transient `MessagingHealthCheck` with custom options in the service collection.

    services: this IServiceCollection
    The service collection to configure.
    configureOptions: Action<MessagingHealthCheckOptions>?
    Optional configuration action for `MessagingHealthCheckOptions`.

    Returns: The configured `IServiceCollection`.

    Exceptions: ArgumentNullException: `services` is `null`

  • methodAddMessagingLivenessCheck
    public static IServiceCollection AddMessagingLivenessCheck(this IServiceCollection services, Action<MessagingHealthCheckOptions>? configureOptions = null)

    Registers a transient `MessagingHealthCheck` configured specifically for process liveness probes.

    services: this IServiceCollection
    The service collection to configure.
    configureOptions: Action<MessagingHealthCheckOptions>?
    Optional configuration action for `MessagingHealthCheckOptions`.

    Returns: The configured `IServiceCollection`.

    Exceptions: ArgumentNullException: `services` is `null`

  • methodAddMessagingReadinessCheck
    public static IServiceCollection AddMessagingReadinessCheck(this IServiceCollection services, Action<MessagingHealthCheckOptions>? configureOptions = null)

    Registers a transient `MessagingHealthCheck` configured specifically for operational readiness probes.

    services: this IServiceCollection
    The service collection to configure.
    configureOptions: Action<MessagingHealthCheckOptions>?
    Optional configuration action for `MessagingHealthCheckOptions`.

    Returns: The configured `IServiceCollection`.

    Exceptions: ArgumentNullException: `services` is `null`

EricksonLopez.Messaging.Analyzers.Analyzers#

5
class

DomainBoundaryAnalyzer

Assembly: EricksonLopez.Messaging.Analyzers
public sealed class DomainBoundaryAnalyzer : DiagnosticAnalyzer
Inherits: DiagnosticAnalyzer

Provides a Roslyn analyzer that ensures message contracts do not reference domain entities or aggregate roots.

Members (2)

  • methodInitialize
    public override void Initialize(AnalysisContext context)

    Inherits documentation from base type or interface.

    context: AnalysisContext
  • propertySupportedDiagnostics
    public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }

    Inherits documentation from base type or interface.

class

HandlerAsyncAnalyzer

Assembly: EricksonLopez.Messaging.Analyzers
public sealed class HandlerAsyncAnalyzer : DiagnosticAnalyzer
Inherits: DiagnosticAnalyzer

Provides a Roslyn analyzer that detects synchronous blocking calls in message handlers.

Members (2)

  • methodInitialize
    public override void Initialize(AnalysisContext context)

    Inherits documentation from base type or interface.

    context: AnalysisContext
  • propertySupportedDiagnostics
    public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }

    Inherits documentation from base type or interface.

class

HandlerMustReturnResultAnalyzer

Assembly: EricksonLopez.Messaging.Analyzers
public sealed class HandlerMustReturnResultAnalyzer : DiagnosticAnalyzer
Inherits: DiagnosticAnalyzer

Provides a Roslyn analyzer that validates message handlers return `ValueTask<Result>` for functional error handling.

Members (2)

  • methodInitialize
    public override void Initialize(AnalysisContext context)

    Inherits documentation from base type or interface.

    context: AnalysisContext
  • propertySupportedDiagnostics
    public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }

    Inherits documentation from base type or interface.

class

InvalidHandlerLifetimeAnalyzer

Assembly: EricksonLopez.Messaging.Analyzers
public sealed class InvalidHandlerLifetimeAnalyzer : DiagnosticAnalyzer
Inherits: DiagnosticAnalyzer

Provides a Roslyn analyzer that enforces scoped service lifetime registrations for message handlers.

Members (2)

  • methodInitialize
    public override void Initialize(AnalysisContext context)

    Inherits documentation from base type or interface.

    context: AnalysisContext
  • propertySupportedDiagnostics
    public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }

    Inherits documentation from base type or interface.

class

MessageTypeAttributeAnalyzer

Assembly: EricksonLopez.Messaging.Analyzers
public sealed class MessageTypeAttributeAnalyzer : DiagnosticAnalyzer
Inherits: DiagnosticAnalyzer

Provides a Roslyn analyzer that verifies all message implementations declare the `[MessageType]` attribute.

Members (2)

  • methodInitialize
    public override void Initialize(AnalysisContext context)

    Inherits documentation from base type or interface.

    context: AnalysisContext
  • propertySupportedDiagnostics
    public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }

    Inherits documentation from base type or interface.

EricksonLopez.Messaging.Analyzers.Rules#

1
class

DiagnosticDescriptors

Assembly: EricksonLopez.Messaging.Analyzers
public static class DiagnosticDescriptors

Provides diagnostic descriptors for Roslyn analyzer rules in the messaging framework.

Members (5)

  • fieldDomainEntityInMessage
    public static readonly DiagnosticDescriptor DomainEntityInMessage

    Gets the diagnostic descriptor for rule ELMSG005, indicating a message contract exposes domain entities or aggregate roots.

  • fieldHandlerMustReturnResult
    public static readonly DiagnosticDescriptor HandlerMustReturnResult

    Gets the diagnostic descriptor for rule ELMSG010, indicating a message handler does not return `ValueTask<Result>`.

  • fieldInvalidHandlerLifetime
    public static readonly DiagnosticDescriptor InvalidHandlerLifetime

    Gets the diagnostic descriptor for rule ELMSG004, indicating a message handler has an invalid service lifetime registration.

  • fieldMissingMessageTypeAttribute
    public static readonly DiagnosticDescriptor MissingMessageTypeAttribute

    Gets the diagnostic descriptor for rule ELMSG002, indicating a message type is missing the `[MessageType]` attribute.

  • fieldSynchronousBlockingInHandler
    public static readonly DiagnosticDescriptor SynchronousBlockingInHandler

    Gets the diagnostic descriptor for rule ELMSG008, indicating a message handler performs synchronous blocking operations.

EricksonLopez.Messaging.Attributes#

2
class

MessageTypeAttribute

Assembly: EricksonLopez.Messaging.Abstractions
public sealed class MessageTypeAttribute : Attribute
Inherits: Attribute

Specifies a stable, cross-platform string identifier for a message type contract.

Members (2)

  • constructorMessageTypeAttribute
    public MessageTypeAttribute(string typeName)

    Initializes a new instance of the `MessageTypeAttribute` class with the specified type identifier.

    typeName: string
    The unique, stable string identifier (e.g., 'orders.order-created.v1').

    Exceptions: ArgumentException: `typeName` is `null`, empty, or consists only of white-space characters

  • propertyTypeName
    public string TypeName { get; }

    Gets the unique string identifier for this message type.

class

PartitionKeyAttribute

Assembly: EricksonLopez.Messaging.Abstractions
public sealed class PartitionKeyAttribute : Attribute
Inherits: Attribute

Specifies that a property within a message contract serves as the partition key for message ordering and routing.

Members (0)

This type declares 0 public members (e.g. marker interface or empty enum/record).

EricksonLopez.Messaging.Contracts#

16
record

DeadLetterReason

Assembly: EricksonLopez.Messaging.Abstractions
public sealed record DeadLetterReason(string ReasonCode, string Description, string? ExceptionType, string? StackTrace, DateTimeOffset OccurredAtUtc)

Represents a structured reason descriptor detailing why a message was diverted to a dead-letter queue.

Members (7)

  • constructorDeadLetterReason
    public DeadLetterReason(string ReasonCode, string Description, string? ExceptionType = null, string? StackTrace = null, DateTimeOffset OccurredAtUtc = default)

    Initializes a new instance of DeadLetterReason.

    ReasonCode: string
    The standardized classification code (e.g., `DESERIALIZATION_FAILURE`, `MAX_RETRIES_EXCEEDED`, `POISON_PAYLOAD`).
    Description: string
    The human-readable explanation of the processing or transport failure.
    ExceptionType: string?
    The fully qualified type name of the originating exception, if available.
    StackTrace: string?
    The stack trace capture of the failure site, if available.
    OccurredAtUtc: DateTimeOffset
    The timestamp when the dead-letter routing was triggered.
  • methodFromException
    public static DeadLetterReason FromException(string reasonCode, string description, Exception? exception = null)

    Creates a new `DeadLetterReason` instance from an optional originating exception.

    reasonCode: string
    The standardized failure classification code.
    description: string
    The descriptive explanation of the failure.
    exception: Exception?
    The captured exception causing the dead-letter redirect, if available.

    Returns: A new `DeadLetterReason` instance containing exception diagnostics.

  • propertyDescription
    public string Description { get; init; }

    The human-readable explanation of the processing or transport failure.

  • propertyExceptionType
    public string? ExceptionType { get; init; }

    The fully qualified type name of the originating exception, if available.

  • propertyOccurredAtUtc
    public DateTimeOffset OccurredAtUtc { get; init; }

    The timestamp when the dead-letter routing was triggered.

  • propertyReasonCode
    public string ReasonCode { get; init; }

    The standardized classification code (e.g., `DESERIALIZATION_FAILURE`, `MAX_RETRIES_EXCEEDED`, `POISON_PAYLOAD`).

  • propertyStackTrace
    public string? StackTrace { get; init; }

    The stack trace capture of the failure site, if available.

interface

IDeadLetterQueue

Assembly: EricksonLopez.Messaging.Abstractions
public interface IDeadLetterQueue

Defines a mechanism for routing poisoned, invalid, or permanently failing messages to a durable dead-letter queue.

Members (2)

  • methodForwardRawToDeadLetterAsync
    ValueTask<Result> ForwardRawToDeadLetterAsync(ReadOnlyMemory<byte> rawPayload, DeadLetterReason reason, TransportMessageMetadata? metadata = null, CancellationToken cancellationToken = default)

    Forwards an unparseable or raw binary payload to the dead-letter destination along with transport metadata.

    rawPayload: ReadOnlyMemory<byte>
    The raw undecodable byte payload.
    reason: DeadLetterReason
    The structured reason justifying dead-letter routing.
    metadata: TransportMessageMetadata?
    The transport metadata associated with the failed frame, if extractable.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating whether the dead-letter routing succeeded.

  • methodForwardToDeadLetterAsync<TMessage>
    ValueTask<Result> ForwardToDeadLetterAsync<TMessage>(TMessage message, DeadLetterReason reason, MessageContext? context = null, CancellationToken cancellationToken = default) where TMessage : notnull

    Forwards a strongly-typed message instance to the dead-letter destination along with diagnostic reason metadata.

    message: TMessage
    The message instance that failed processing.
    reason: DeadLetterReason
    The structured reason justifying dead-letter routing.
    context: MessageContext?
    The ambient message consumption context, if present.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating whether the dead-letter routing succeeded.

    Type parameters: TMessage: The type of the message payload.

interface

IMessage

Assembly: EricksonLopez.Messaging.Abstractions
public interface IMessage

Defines a marker interface for all strongly-typed messages transmitted across the messaging system.

Members (0)

This type declares 0 public members (e.g. marker interface or empty enum/record).

interface

IMessageConsumer

Assembly: EricksonLopez.Messaging.Abstractions
public interface IMessageConsumer

Defines a message consumer lifecycle manager responsible for subscription, ingestion, and graceful shutdown.

Members (3)

  • methodDrainInFlightMessagesAsync
    ValueTask DrainInFlightMessagesAsync(CancellationToken cancellationToken = default)

    Drains in-flight messages currently processing in handler pipelines.

    cancellationToken: CancellationToken
    A token that can be used to cancel the drain operation.

    Returns: A value task representing the asynchronous operation.

  • methodStartAsync
    ValueTask StartAsync(CancellationToken cancellationToken = default)

    Starts consuming messages from configured transport channels.

    cancellationToken: CancellationToken
    A token that can be used to cancel the startup operation.

    Returns: A value task representing the asynchronous operation.

  • methodStopReceivingAsync
    ValueTask StopReceivingAsync()

    Stops accepting new messages from the underlying transport during application shutdown.

    Returns: A value task representing the asynchronous operation.

interface

IMessageDeduplicationStore

Assembly: EricksonLopez.Messaging.Abstractions
public interface IMessageDeduplicationStore : IDisposable
Implements: IDisposable

Defines an abstraction for verifying message idempotency and acquiring processing rights to prevent duplicate execution.

Members (2)

  • methodReleaseAsync
    ValueTask ReleaseAsync(string messageId, CancellationToken cancellationToken = default)

    Releases the idempotency lock for the specified message identity, allowing it to be retried.

    messageId: string
    The unique identity of the message.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation.

  • methodTryAcquireAsync
    ValueTask<bool> TryAcquireAsync(string messageId, TimeSpan expiration, CancellationToken cancellationToken = default)

    Attempts to acquire an idempotency lock for the specified message identity.

    messageId: string
    The unique identity of the message.
    expiration: TimeSpan
    The maximum duration to retain the deduplication state.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains `true` if the lock was successfully acquired; otherwise, `false` if the message is a duplicate.

interface

IMessageHandler<TMessage>

Assembly: EricksonLopez.Messaging.Abstractions
public interface IMessageHandler<TMessage> where TMessage : notnull

Defines a strongly-typed consumer handler for processing distributed messages.

Remarks:

Type parameters: TMessage: The type of message payload to handle.

Members (1)

  • methodHandleAsync
    ValueTask<Result> HandleAsync(TMessage message, MessageContext context, CancellationToken cancellationToken = default)

    Handles the specified message asynchronously and returns a functional `Result`.

    message: TMessage
    The incoming strongly-typed message instance to handle.
    context: MessageContext
    The ambient execution context containing metadata, scope, and items.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` representing the processing outcome.

interface

IMessagePublisher

Assembly: EricksonLopez.Messaging.Abstractions
public interface IMessagePublisher

Defines a message publisher for emitting strongly-typed messages to distributed brokers.

Members (4)

  • methodPublishAsync<TMessage>
    ValueTask<Result> PublishAsync<TMessage>(TMessage message, MessagePublishOptions? options = null, CancellationToken cancellationToken = default) where TMessage : notnull

    Publishes a message to all interested subscribers.

    message: TMessage
    The message instance to publish.
    options: MessagePublishOptions?
    The publish configuration tailoring destination, headers, and keys, if specified.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating whether the transport acknowledged the message.

    Type parameters: TMessage: The type of the message payload.

  • methodPublishBatchAsync<TMessage>
    ValueTask<Result> PublishBatchAsync<TMessage>(IEnumerable<TMessage> messages, MessagePublishOptions? options = null, CancellationToken cancellationToken = default) where TMessage : notnull

    Publishes a batch of messages to all interested subscribers in a single operation.

    messages: IEnumerable<TMessage>
    The collection of message instances to publish.
    options: MessagePublishOptions?
    The publish configuration tailoring destination, headers, and keys, if specified.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating whether the batch was acknowledged.

    Type parameters: TMessage: The type of the message payload.

  • methodSendAsync<TMessage>
    ValueTask<Result> SendAsync<TMessage>(TMessage message, string destination, MessageSendOptions? options = null, CancellationToken cancellationToken = default) where TMessage : notnull

    Sends a point-to-point command message directly to a target destination or queue.

    message: TMessage
    The message instance to send.
    destination: string
    The target queue, topic, or endpoint name.
    options: MessageSendOptions?
    The send configuration tailoring headers and metadata, if specified.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating whether the transport acknowledged the message.

    Type parameters: TMessage: The type of the command message payload.

  • methodSendBatchAsync<TMessage>
    ValueTask<Result> SendBatchAsync<TMessage>(IEnumerable<TMessage> messages, string destination, MessageSendOptions? options = null, CancellationToken cancellationToken = default) where TMessage : notnull

    Sends a batch of point-to-point command messages directly to a target destination or queue in a single operation.

    messages: IEnumerable<TMessage>
    The collection of message instances to send.
    destination: string
    The target queue, topic, or endpoint name.
    options: MessageSendOptions?
    The send configuration tailoring headers and metadata, if specified.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating whether the batch was acknowledged.

    Type parameters: TMessage: The type of the command message payload.

interface

IMessageSerializer

Assembly: EricksonLopez.Messaging.Abstractions
public interface IMessageSerializer

Defines serialization and deserialization operations for messaging payloads.

Members (5)

  • methodDeserialize
    object Deserialize(ReadOnlyMemory<byte> bytes, Type messageType)

    Deserializes binary payload data into an object instance of the specified runtime type.

    bytes: ReadOnlyMemory<byte>
    The raw binary payload segment.
    messageType: Type
    The expected target runtime type.

    Returns: The deserialized message instance.

  • methodDeserialize<T>
    T Deserialize<T>(ReadOnlyMemory<byte> bytes)

    Deserializes binary payload data into a strongly-typed message instance.

    bytes: ReadOnlyMemory<byte>
    The raw binary payload segment.

    Returns: The deserialized message instance.

    Type parameters: T: The expected message type.

  • methodSerialize<T>
    ReadOnlyMemory<byte> Serialize<T>(T message) where T : notnull

    Serializes a strongly-typed message payload into an immutable memory segment.

    message: T
    The message instance to serialize.

    Returns: A `ReadOnlyMemory<T>` containing the serialized payload bytes.

    Type parameters: T: The message payload type.

  • methodSerialize<T>
    void Serialize<T>(T message, IBufferWriter<byte> writer) where T : notnull

    Serializes a strongly-typed message payload directly into a buffer writer.

    message: T
    The message instance to serialize.
    writer: IBufferWriter<byte>
    The target buffer writer receiving the encoded bytes.

    Type parameters: T: The message payload type.

  • propertyContentType
    string ContentType { get; }

    Gets the media content type identifier associated with this serializer (e.g., `application/json`).

interface

IMessageUpcaster<TOldMessage, TNewMessage>

Assembly: EricksonLopez.Messaging.Abstractions
public interface IMessageUpcaster<TOldMessage, TNewMessage> where TOldMessage : class, IMessage where TNewMessage : class, IMessage

Defines a transformation mechanism for upgrading an older schema version of a message into a newer schema version.

Remarks:

Type parameters: TOldMessage: The previous message contract type.; TNewMessage: The upgraded target message contract type.

Members (1)

  • methodUpcast
    TNewMessage Upcast(TOldMessage oldMessage, TransportMessageMetadata metadata)

    Converts an older message payload to the newer message contract.

    oldMessage: TOldMessage
    The incoming source message instance.
    metadata: TransportMessageMetadata
    The message metadata associated with the incoming envelope.

    Returns: The upgraded message instance.

interface

IPartitionKeyResolver

Assembly: EricksonLopez.Messaging.Abstractions
public interface IPartitionKeyResolver

Provides a mechanism to extract partition keys from messages without using reflection.

Remarks:

This interface is typically implemented via source generators for Native AOT compatibility.

Members (1)

  • methodResolve<TMessage>
    string? Resolve<TMessage>(TMessage message) where TMessage : notnull

    Attempts to extract a partition key from the provided message.

    message: TMessage
    The message instance.

    Returns: The extracted partition key, or `null` if the message does not define one or cannot be extracted.

    Type parameters: TMessage: The type of the message.

class

MessageContext

Assembly: EricksonLopez.Messaging.Abstractions
public class MessageContext

Encapsulates ambient execution context supplied to message handlers and middleware during message consumption.

Members (6)

  • constructorMessageContext
    public MessageContext(TransportMessageMetadata metadata, IServiceProvider serviceProvider, CancellationToken cancellationToken = default)

    Initializes a new instance of the `MessageContext` class with the specified metadata and service provider.

    metadata: TransportMessageMetadata
    The transport metadata associated with the incoming message.
    serviceProvider: IServiceProvider
    The scoped service provider for dependency resolution within the message execution scope.
    cancellationToken: CancellationToken
    A token that can be used to cancel the message processing.

    Exceptions: ArgumentNullException: `metadata` or `serviceProvider` is `null`

  • propertyCancellationToken
    public CancellationToken CancellationToken { get; set; }

    Gets or sets the cancellation token that signals the current message execution should be abandoned.

    Exceptions: ObjectDisposedException: The context has completed its execution scope and been returned to the object pool

  • propertyItems
    public IDictionary<string, object?> Items { get; }

    Gets a mutable dictionary for sharing arbitrary state between middleware components and the terminal handler within a single message execution.

    Keys are compared using ordinal string comparison. Never returns `null`. Lazily initialized on first access. Exceptions: ObjectDisposedException: The context has completed its execution scope and been returned to the object pool

  • propertyMessage
    public virtual object? Message { get; set; }

    Gets or sets the deserialized message payload instance, which middleware components may replace during upcasting.

    Middleware components such as the message upcasting middleware may assign an upgraded schema version to this property before the terminal handler is invoked. Exceptions: ObjectDisposedException: The context has completed its execution scope and been returned to the object pool

  • propertyMetadata
    public TransportMessageMetadata Metadata { get; internal set; }

    Gets the metadata associated with the current message.

    Exceptions: ObjectDisposedException: The context has completed its execution scope and been returned to the object pool

  • propertyServiceProvider
    public IServiceProvider ServiceProvider { get; internal set; }

    Gets the scoped service provider configured for this execution scope.

    Exceptions: ObjectDisposedException: The context has completed its execution scope and been returned to the object pool

record

MessageDispatchItem

Assembly: EricksonLopez.Messaging.Abstractions
public readonly record struct MessageDispatchItem(string MessageType, ReadOnlyMemory<byte> Payload, TransportMessageMetadata Metadata)

Represents an item in a batch message dispatch operation.

Members (4)

  • constructorMessageDispatchItem
    public MessageDispatchItem(string MessageType, ReadOnlyMemory<byte> Payload, TransportMessageMetadata Metadata)

    Initializes a new instance of MessageDispatchItem.

    MessageType: string
    The message type identifier.
    Payload: ReadOnlyMemory<byte>
    The raw message payload bytes.
    Metadata: TransportMessageMetadata
    The accompanying message metadata.
  • propertyMessageType
    public string MessageType { get; init; }

    The message type identifier.

  • propertyMetadata
    public TransportMessageMetadata Metadata { get; init; }

    The accompanying message metadata.

  • propertyPayload
    public ReadOnlyMemory<byte> Payload { get; init; }

    The raw message payload bytes.

record

MessageEnvelope<TMessage>

Assembly: EricksonLopez.Messaging.Abstractions
public sealed record MessageEnvelope<TMessage>(TMessage Payload, TransportMessageMetadata Metadata) where TMessage : notnull

Represents a strongly-typed carrier envelope bundling a message payload with its transport metadata.

Remarks:

Type parameters: TMessage: The type of the message payload.

Members (4)

  • constructorMessageEnvelope
    public MessageEnvelope(TMessage Payload, TransportMessageMetadata Metadata)

    Initializes a new instance of MessageEnvelope<TMessage>.

    Payload: TMessage
    The business payload instance.
    Metadata: TransportMessageMetadata
    The accompanying transport metadata.

    Type parameters: TMessage: The type of the message payload.

  • methodCreate
    public static MessageEnvelope<TMessage> Create(TMessage payload, string messageType, string? correlationId = null, string? causationId = null, string? traceParent = null, string? tenantId = null, string? partitionKey = null, int schemaVersion = 1)

    Creates a new `MessageEnvelope<TMessage>` instance with initialized metadata.

    payload: TMessage
    The business payload instance.
    messageType: string
    The message type identifier.
    correlationId: string?
    The correlation identifier for distributed tracing.
    causationId: string?
    The causation identifier of the triggering message.
    traceParent: string?
    The W3C trace parent header value.
    tenantId: string?
    The identifier of the tenant context.
    partitionKey: string?
    The partition key for sharded messaging.
    schemaVersion: int
    The schema version number.

    Returns: A new `MessageEnvelope<TMessage>` instance containing the payload and metadata.

    Exceptions: ArgumentNullException: `payload` is `null`; ArgumentException: `messageType` is `null`, empty, or consists only of white-space characters

  • propertyMetadata
    public TransportMessageMetadata Metadata { get; init; }

    The accompanying transport metadata.

  • propertyPayload
    public TMessage Payload { get; init; }

    The business payload instance.

class

MessagePublishOptions

Assembly: EricksonLopez.Messaging.Abstractions
public sealed class MessagePublishOptions

Specifies configuration options for publishing messages to multiple subscribers.

Members (6)

  • propertyCausationId
    public string? CausationId { get; set; }

    Gets or sets the causation identifier of the triggering message or event.

  • propertyCorrelationId
    public string? CorrelationId { get; set; }

    Gets or sets the correlation identifier for end-to-end distributed tracing.

  • propertyDestination
    public string? Destination { get; set; }

    Gets or sets the custom destination topic or exchange name.

  • propertyHeaders
    public IReadOnlyDictionary<string, string>? Headers { get; set; }

    Gets or sets custom key-value headers attached to the message envelope.

  • propertyPartitionKey
    public string? PartitionKey { get; set; }

    Gets or sets the partition key for deterministic message ordering across partitions.

  • propertyTenantId
    public string? TenantId { get; set; }

    Gets or sets the tenant identifier for multi-tenant isolation and routing.

class

MessageSendOptions

Assembly: EricksonLopez.Messaging.Abstractions
public sealed class MessageSendOptions

Specifies configuration options for sending point-to-point command messages.

Members (5)

  • propertyCausationId
    public string? CausationId { get; set; }

    Gets or sets the causation identifier of the triggering message or event.

  • propertyCorrelationId
    public string? CorrelationId { get; set; }

    Gets or sets the correlation identifier for end-to-end distributed tracing.

  • propertyHeaders
    public IReadOnlyDictionary<string, string>? Headers { get; set; }

    Gets or sets custom key-value headers attached to the message envelope.

  • propertyPartitionKey
    public string? PartitionKey { get; set; }

    Gets or sets the partition key for deterministic message ordering across partitions.

  • propertyTenantId
    public string? TenantId { get; set; }

    Gets or sets the tenant identifier for multi-tenant isolation and routing.

record

TransportMessageMetadata

Assembly: EricksonLopez.Messaging.Abstractions
public record TransportMessageMetadata(string MessageId, string MessageType, DateTimeOffset Timestamp, string CorrelationId, string? CausationId, string? TraceParent, string? TenantId, string? PartitionKey, string ContentType, int SchemaVersion, IReadOnlyDictionary<string, string>? Headers)

Represents metadata associated with a message for distributed routing, tracing, and transport concerns.

Members (14)

  • constructorTransportMessageMetadata
    public TransportMessageMetadata(string MessageId, string MessageType, DateTimeOffset Timestamp, string CorrelationId, string? CausationId = null, string? TraceParent = null, string? TenantId = null, string? PartitionKey = null, string ContentType = "", int SchemaVersion = 1, IReadOnlyDictionary<string, string>? Headers = null)

    Initializes a new instance of TransportMessageMetadata.

    MessageId: string
    The unique identifier of the message.
    MessageType: string
    The stable string type identifier representing the payload schema.
    Timestamp: DateTimeOffset
    The UTC timestamp indicating when the message was generated.
    CorrelationId: string
    The correlation identifier for end-to-end distributed tracing.
    CausationId: string?
    The causation identifier indicating the originating event or command, if available.
    TraceParent: string?
    The W3C traceparent string for distributed OpenTelemetry propagation, if available.
    TenantId: string?
    The tenant identifier for multi-tenant isolation and routing, if available.
    PartitionKey: string?
    The partition key for deterministic sharded ordering, if available.
    ContentType: string
    The MIME content type of the serialized payload.
    SchemaVersion: int
    The integer version of the payload schema contract.
    Headers: IReadOnlyDictionary<string, string>?
    The custom key-value headers for transport extensions, if available.
  • methodCreate
    public static TransportMessageMetadata Create(string messageType, string? correlationId = null, string? causationId = null, string? traceParent = null, string? tenantId = null, string? partitionKey = null, int schemaVersion = 1, IReadOnlyDictionary<string, string>? headers = null)

    Creates a new `TransportMessageMetadata` instance with a generated message identifier, current UTC timestamp, and the specified optional fields.

    messageType: string
    The stable string identifier for the message schema contract (e.g., `orders.order-created.v1`).
    correlationId: string?
    The correlation identifier for distributed tracing. When `null`, defaults to the generated `MessageId`.
    causationId: string?
    The causation identifier of the triggering message, if available.
    traceParent: string?
    The W3C traceparent header value for OpenTelemetry propagation, if available.
    tenantId: string?
    The identifier of the tenant context, if applicable.
    partitionKey: string?
    The partition key for sharded message ordering, if applicable.
    schemaVersion: int
    The integer version of the payload schema contract. Defaults to `1`.
    headers: IReadOnlyDictionary<string, string>?
    The custom key-value transport extension headers, if any.

    Returns: A new `TransportMessageMetadata` instance with a generated `MessageId`, the current UTC timestamp as `Timestamp`, and a resolved `CorrelationId` (defaulting to `MessageId` when `correlationId` is `null`).

    Exceptions: ArgumentException: `messageType` is `null`, empty, or consists only of white-space characters

  • propertyCausationId
    public string? CausationId { get; init; }

    The causation identifier indicating the originating event or command, if available.

  • propertyContentType
    public string ContentType { get; init; }

    The MIME content type of the serialized payload.

  • propertyCorrelationId
    public string CorrelationId { get; init; }

    The correlation identifier for end-to-end distributed tracing.

  • propertyHeaders
    public IReadOnlyDictionary<string, string>? Headers { get; init; }

    The custom key-value headers for transport extensions, if available.

  • propertyMessageId
    public string MessageId { get; init; }

    The unique identifier of the message.

  • propertyMessageIdGenerator
    public static Func<string> MessageIdGenerator { get; set; }

    Gets or sets the generator function used to produce unique 32-character message identifiers. Defaults to monotonic UUIDv7 formatted as a 32-character hexadecimal string without hyphens.

  • propertyMessageType
    public string MessageType { get; init; }

    The stable string type identifier representing the payload schema.

  • propertyPartitionKey
    public string? PartitionKey { get; init; }

    The partition key for deterministic sharded ordering, if available.

  • propertySchemaVersion
    public int SchemaVersion { get; init; }

    The integer version of the payload schema contract.

  • propertyTenantId
    public string? TenantId { get; init; }

    The tenant identifier for multi-tenant isolation and routing, if available.

  • propertyTimestamp
    public DateTimeOffset Timestamp { get; init; }

    The UTC timestamp indicating when the message was generated.

  • propertyTraceParent
    public string? TraceParent { get; init; }

    The W3C traceparent string for distributed OpenTelemetry propagation, if available.

EricksonLopez.Messaging.Diagnostics#

1
class

MessagingDiagnostics

Assembly: EricksonLopez.Messaging
public static class MessagingDiagnostics

Provides canonical OpenTelemetry `ActivitySource` and `Meter` instances for distributed messaging diagnostics.

Members (16)

  • methodCreateMessageTypeTags
    public static TagList CreateMessageTypeTags(string messageType)

    Creates a stack-allocated `TagList` containing the standard message type dimension.

    messageType: string
    The message type name to associate with the metric.

    Returns: A stack-allocated `TagList` with 0 heap allocation.

  • methodDecrementInFlight
    public static void DecrementInFlight()

    Decrements the total count of active in-flight messages.

  • methodIncrementInFlight
    public static void IncrementInFlight()

    Increments the total count of active in-flight messages.

  • propertyInFlightCount
    public static int InFlightCount { get; }

    Gets the current number of in-flight messages being processed across all consumer instances.

  • fieldActivitySource
    public static readonly ActivitySource ActivitySource

    Gets the shared `ActivitySource` for distributed tracing across messaging operations.

  • fieldActivitySourceName
    public const string ActivitySourceName

    Gets the canonical identifier name for OpenTelemetry activity tracing.

  • fieldInFlightMessages
    public static readonly ObservableUpDownCounter<int> InFlightMessages

    Gets the observable up-down counter tracking active in-flight messages being processed.

  • fieldMessagesDeduplicated
    public static readonly Counter<long> MessagesDeduplicated

    Gets the counter instrument recording the total number of duplicate messages detected and skipped.

  • fieldMessagesFailed
    public static readonly Counter<long> MessagesFailed

    Gets the counter instrument recording the total number of failed message processing attempts.

  • fieldMessagesPublished
    public static readonly Counter<long> MessagesPublished

    Gets the counter instrument recording the total number of published messages.

  • fieldMessagesReceived
    public static readonly Counter<long> MessagesReceived

    Gets the counter instrument recording the total number of received messages.

  • fieldMeter
    public static readonly Meter Meter

    Gets the shared `Meter` for publishing messaging operational metrics.

  • fieldMeterName
    public const string MeterName

    Gets the canonical identifier name for OpenTelemetry metrics collection.

  • fieldProcessingDuration
    public static readonly Histogram<double> ProcessingDuration

    Gets the histogram instrument tracking message processing latency in milliseconds.

  • fieldTagMessageType
    public const string TagMessageType

    Standard OpenTelemetry dimensional tag for message type classification.

  • fieldVersion
    public const string Version

    Gets the messaging framework version tag.

EricksonLopez.Messaging.Dispatch#

9
class

DefaultMessageDispatcher

Assembly: EricksonLopez.Messaging
public sealed class DefaultMessageDispatcher : IMessageDispatcher, IHandlerRegistry
Implements: IHandlerRegistry, IMessageDispatcher

Dispatches incoming raw serialized payloads and metadata to registered strongly-typed handlers through precompiled invokers and middleware.

Members (4)

  • constructorDefaultMessageDispatcher
    public DefaultMessageDispatcher(IMessageSerializer serializer, IEnumerable<IMessageMiddleware>? middlewares = null, IDictionary<string, IReadOnlyList<HandlerBinding>>? bindings = null, IEnumerable<IHandlerRegistration>? registrations = null, IEnumerable<IMessageUpcasterInvoker>? upcasters = null, ObjectPool<MessageContext>? contextPool = null)

    Initializes a new instance of the `DefaultMessageDispatcher` class with the specified serializer, middlewares, registrations, and optional context pool.

    serializer: IMessageSerializer
    The message serializer used for payload deserialization.
    middlewares: IEnumerable<IMessageMiddleware>?
    The collection of middleware components to execute during dispatch, if any.
    bindings: IDictionary<string, IReadOnlyList<HandlerBinding>>?
    The dictionary of preconfigured handler bindings, if any.
    registrations: IEnumerable<IHandlerRegistration>?
    The collection of discovered handler registrations to configure, if any.
    upcasters: IEnumerable<IMessageUpcasterInvoker>?
    The collection of registered message upcasters for schema version migration, if any.
    contextPool: ObjectPool<MessageContext>?
    The optional object pool for recycling `MessageContext` instances, if any.

    Exceptions: ArgumentNullException: `serializer` is `null`

  • methodDispatchAsync
    public async ValueTask<Result> DispatchAsync(string messageType, ReadOnlyMemory<byte> payload, TransportMessageMetadata metadata, IServiceProvider serviceProvider, CancellationToken cancellationToken = default)

    Deserializes the message payload and executes the corresponding handler through the middleware pipeline.

    messageType: string
    The message type identifier.
    payload: ReadOnlyMemory<byte>
    The raw message payload bytes.
    metadata: TransportMessageMetadata
    The accompanying message metadata.
    serviceProvider: IServiceProvider
    The service provider for dependency resolution within the execution scope.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the dispatch and handler execution outcome.

    Exceptions: ArgumentException: `messageType` is `null`, empty, or consists only of white-space characters; ArgumentNullException: `metadata` or `serviceProvider` is `null`

  • methodDispatchBatchAsync
    public async ValueTask<Result> DispatchBatchAsync(IEnumerable<MessageDispatchItem> items, IServiceProvider serviceProvider, CancellationToken cancellationToken = default)

    Deserializes a batch of message items and executes their corresponding handlers through the middleware pipeline.

    items: IEnumerable<MessageDispatchItem>
    The collection of message items to dispatch.
    serviceProvider: IServiceProvider
    The service provider for dependency resolution within the execution scope.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating whether all items in the batch dispatched successfully or if any item failed.

    Exceptions: ArgumentNullException: `items` or `serviceProvider` is `null`

  • methodRegisterHandler<TMessage, THandler>
    public void RegisterHandler<TMessage, THandler>(string typeName) where TMessage : notnull where THandler : notnull, IMessageHandler<TMessage>

    Registers a handler binding for the specified message type identifier.

    typeName: string
    The unique message type identifier to associate with the handler.

    Type parameters: TMessage: The type of the message payload to handle.; THandler: The type of the message handler. Exceptions: ArgumentException: `typeName` is `null`, empty, or consists only of white-space characters

record

DefaultMessageDispatcher.HandlerBinding

Assembly: EricksonLopez.Messaging
public sealed record HandlerBinding(Type MessageType, Type HandlerType, Func<IServiceProvider, object, MessageContext, CancellationToken, ValueTask<Result>> Invoker)

Represents a compiled binding between a message type, its handler type, and an asynchronous invocation delegate.

Members (4)

  • constructorHandlerBinding
    public HandlerBinding(Type MessageType, Type HandlerType, Func<IServiceProvider, object, MessageContext, CancellationToken, ValueTask<Result>> Invoker)

    Initializes a new instance of HandlerBinding.

    MessageType: Type
    The CLR type of the message.
    HandlerType: Type
    The CLR type of the handler.
    Invoker: Func<IServiceProvider, object, MessageContext, CancellationToken, ValueTask<Result>>
    The asynchronous invocation delegate.
  • propertyHandlerType
    public Type HandlerType { get; init; }

    The CLR type of the handler.

  • propertyInvoker
    public Func<IServiceProvider, object, MessageContext, CancellationToken, ValueTask<Result>> Invoker { get; init; }

    The asynchronous invocation delegate.

  • propertyMessageType
    public Type MessageType { get; init; }

    The CLR type of the message.

class

HandlerRegistrationBase

Assembly: EricksonLopez.Messaging
public abstract class HandlerRegistrationBase : IHandlerRegistration
Implements: IHandlerRegistration

Provides an abstract base class for handler registrations with common type identifier storage.

Members (3)

  • methodRegister
    public abstract void Register(DefaultMessageDispatcher dispatcher)

    Registers the handler binding with the target message dispatcher.

    dispatcher: DefaultMessageDispatcher
    The dispatcher instance to configure.
  • methodRegister
    public virtual void Register(IHandlerRegistry registry)

    Registers the handler binding with the target message dispatcher.

    registry: IHandlerRegistry
  • propertyTypeName
    public string TypeName { get; }

    Gets the unique string message type identifier.

interface

IHandlerRegistration

Assembly: EricksonLopez.Messaging
public interface IHandlerRegistration

Defines a deferred handler registration binding executed during dispatcher initialization.

Members (3)

  • methodRegister
    void Register(DefaultMessageDispatcher dispatcher)

    Registers the handler binding with the target message dispatcher.

    dispatcher: DefaultMessageDispatcher
    The dispatcher instance to configure.
  • methodRegister
    void Register(IHandlerRegistry registry)

    Registers the handler binding with the target handler registry.

    registry: IHandlerRegistry
    The handler registry to configure.
  • propertyTypeName
    string TypeName { get; }

    Gets the unique string message type identifier.

interface

IHandlerRegistry

Assembly: EricksonLopez.Messaging
public interface IHandlerRegistry

Defines an abstraction for registering message handler bindings with a dispatcher.

Members (1)

  • methodRegisterHandler<TMessage, THandler>
    void RegisterHandler<TMessage, THandler>(string typeName) where TMessage : notnull where THandler : notnull, IMessageHandler<TMessage>

    Registers a handler binding for the specified message type identifier.

    typeName: string
    The unique message type identifier to associate with the handler.

    Type parameters: TMessage: The type of the message payload to handle.; THandler: The type of the message handler.

interface

IMessageDispatcher

Assembly: EricksonLopez.Messaging
public interface IMessageDispatcher

Defines a message dispatcher for routing incoming raw payloads and metadata to registered handlers.

Members (2)

  • methodDispatchAsync
    ValueTask<Result> DispatchAsync(string messageType, ReadOnlyMemory<byte> payload, TransportMessageMetadata metadata, IServiceProvider serviceProvider, CancellationToken cancellationToken = default)

    Deserializes the message payload and executes the corresponding handler through the middleware pipeline.

    messageType: string
    The message type identifier.
    payload: ReadOnlyMemory<byte>
    The raw message payload bytes.
    metadata: TransportMessageMetadata
    The accompanying message metadata.
    serviceProvider: IServiceProvider
    The service provider for dependency resolution within the execution scope.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the dispatch and handler execution outcome.

    Exceptions: ArgumentException: `messageType` is `null`, empty, or consists only of white-space characters; ArgumentNullException: `metadata` or `serviceProvider` is `null`; OperationCanceledException: `cancellationToken` has been cancelled before or during dispatch

  • methodDispatchBatchAsync
    ValueTask<Result> DispatchBatchAsync(IEnumerable<MessageDispatchItem> items, IServiceProvider serviceProvider, CancellationToken cancellationToken = default)

    Deserializes a batch of message items and executes their corresponding handlers through the middleware pipeline.

    items: IEnumerable<MessageDispatchItem>
    The collection of message items to dispatch.
    serviceProvider: IServiceProvider
    The service provider for dependency resolution within the execution scope.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating whether all items in the batch dispatched successfully or if any item failed.

    Exceptions: ArgumentNullException: `items` or `serviceProvider` is `null`

class

MessageConsumer

Assembly: EricksonLopez.Messaging
public sealed class MessageConsumer : IMessageConsumer, IAsyncDisposable, IDisposable
Implements: IAsyncDisposable, IDisposable, IMessageConsumer

Provides message consumption management including endpoint subscriptions, concurrency limits, scoped execution, and graceful shutdown.

Members (8)

  • constructorMessageConsumer
    public MessageConsumer(IMessageTransport transport, IMessageDispatcher dispatcher, IServiceScopeFactory scopeFactory, IEnumerable<string>? subscribedDestinations = null, IEnumerable<IHandlerRegistration>? registrations = null, ILogger<MessageConsumer>? logger = null, IOptions<MessageConsumerOptions>? options = null)

    Initializes a new instance of the `MessageConsumer` class with the specified transport, dispatcher, and scope factory.

    transport: IMessageTransport
    The message transport implementation.
    dispatcher: IMessageDispatcher
    The message dispatcher for processing received payloads.
    scopeFactory: IServiceScopeFactory
    The service scope factory for creating message execution scopes.
    subscribedDestinations: IEnumerable<string>?
    The collection of destination queues or topics to subscribe to, if specified.
    registrations: IEnumerable<IHandlerRegistration>?
    The collection of discovered handler registrations, if specified.
    logger: ILogger<MessageConsumer>?
    The logger instance, if specified.
    options: IOptions<MessageConsumerOptions>?
    The consumer options, if specified.

    Exceptions: ArgumentNullException: `transport`, `dispatcher`, or `scopeFactory` is `null`

  • methodAddDestination
    public void AddDestination(string destination)

    Adds an additional destination queue or topic for subscription prior to starting the consumer.

    destination: string
    The destination queue or topic name to subscribe to.

    Exceptions: ArgumentException: `destination` is `null`, empty, or consists only of white-space characters

  • methodDispose
    public void Dispose()

    Releases the resources used by this instance.

  • methodDisposeAsync
    public async ValueTask DisposeAsync()

    Asynchronously releases the resources used by this instance.

    Returns: A value task representing the asynchronous disposal operation.

  • methodDrainInFlightMessagesAsync
    public async ValueTask DrainInFlightMessagesAsync(CancellationToken cancellationToken = default)

    Drains in-flight messages currently processing in handler pipelines.

    cancellationToken: CancellationToken
    A token that can be used to cancel the drain operation.

    Returns: A value task representing the asynchronous operation.

  • methodStartAsync
    public async ValueTask StartAsync(CancellationToken cancellationToken = default)

    Starts consuming messages from configured transport channels.

    cancellationToken: CancellationToken
    A token that can be used to cancel the startup operation.

    Returns: A value task representing the asynchronous operation.

    Subscribes to all registered destinations sequentially. Each destination is configured with a concurrency limit of `Environment.ProcessorCount * 2` and a prefetch count of `20` by default. These values are currently not configurable externally; use a custom `IMessageConsumer` implementation if different concurrency settings are required.

  • methodStopReceivingAsync
    public ValueTask StopReceivingAsync()

    Stops accepting new messages from the underlying transport during application shutdown.

    Returns: A value task representing the asynchronous operation.

  • propertyInFlightCount
    public int InFlightCount { get; }

    Gets the current number of in-flight messages being processed by this consumer instance.

class

MessageConsumerOptions

Assembly: EricksonLopez.Messaging
public sealed class MessageConsumerOptions

Provides configuration options for `MessageConsumer` execution.

Members (3)

  • propertyMaxConcurrency
    public int MaxConcurrency { get; set; }

    Gets or sets the maximum number of concurrent message handlers executing simultaneously. Default is `Environment.ProcessorCount * 2` (minimum 1).

  • propertyPrefetchCount
    public int PrefetchCount { get; set; }

    Gets or sets the number of messages to prefetch from the underlying transport. Default is 20.

  • propertyUnhandledFailureAckResult
    public TransportAckResult UnhandledFailureAckResult { get; set; }

    Gets or sets the acknowledgement outcome to return when message dispatch fails functionally and no `Contracts.IDeadLetterQueue` is registered. The default is `TransportAckResult.NackRequeue` to ensure at-least-once delivery and prevent silent message loss. When using physical brokers with native dead-letter queues, set this to `TransportAckResult.DeadLetter`. Set this to `TransportAckResult.Ack` only if silent discard of failed unrouted messages is explicitly desired.

class

MessagePublisher

Assembly: EricksonLopez.Messaging
public sealed class MessagePublisher : IMessagePublisher
Implements: IMessagePublisher

Publishes strongly-typed messages to distributed message transports with serialization, diagnostics, and metadata propagation.

Members (5)

  • constructorMessagePublisher
    public MessagePublisher(IMessageTransport transport, IMessageSerializer serializer, IEnumerable<IPartitionKeyResolver>? partitionKeyResolvers = null)

    Initializes a new instance of the `MessagePublisher` class with the specified transport and serializer.

    transport: IMessageTransport
    The message transport implementation.
    serializer: IMessageSerializer
    The message serializer used for encoding message payloads.
    partitionKeyResolvers: IEnumerable<IPartitionKeyResolver>?
    Optional list of partition key resolvers for AOT-safe extraction.

    Exceptions: ArgumentNullException: `transport` or `serializer` is `null`

  • methodPublishAsync<TMessage>
    public async ValueTask<Result> PublishAsync<TMessage>(TMessage message, MessagePublishOptions? options = null, CancellationToken cancellationToken = default) where TMessage : notnull

    Publishes a message to all interested subscribers.

    message: TMessage
    The message instance to publish.
    options: MessagePublishOptions?
    The publish configuration tailoring destination, headers, and keys, if specified.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating whether the transport acknowledged the message.

    Type parameters: TMessage: The type of the message payload.

  • methodPublishBatchAsync<TMessage>
    public async ValueTask<Result> PublishBatchAsync<TMessage>(IEnumerable<TMessage> messages, MessagePublishOptions? options = null, CancellationToken cancellationToken = default) where TMessage : notnull

    Publishes a batch of messages to all interested subscribers in a single operation.

    messages: IEnumerable<TMessage>
    The collection of message instances to publish.
    options: MessagePublishOptions?
    The publish configuration tailoring destination, headers, and keys, if specified.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating whether the batch was acknowledged.

    Type parameters: TMessage: The type of the message payload. Exceptions: ArgumentNullException: `messages` is `null`

  • methodSendAsync<TMessage>
    public async ValueTask<Result> SendAsync<TMessage>(TMessage message, string destination, MessageSendOptions? options = null, CancellationToken cancellationToken = default) where TMessage : notnull

    Sends a point-to-point command message directly to a target destination or queue.

    message: TMessage
    The message instance to send.
    destination: string
    The target queue, topic, or endpoint name.
    options: MessageSendOptions?
    The send configuration tailoring headers and metadata, if specified.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating whether the transport acknowledged the message.

    Type parameters: TMessage: The type of the command message payload. Exceptions: ArgumentNullException: `message` is `null`; ArgumentException: `destination` is `null`, empty, or consists only of white-space characters

  • methodSendBatchAsync<TMessage>
    public async ValueTask<Result> SendBatchAsync<TMessage>(IEnumerable<TMessage> messages, string destination, MessageSendOptions? options = null, CancellationToken cancellationToken = default) where TMessage : notnull

    Sends a batch of point-to-point command messages directly to a target destination or queue in a single operation.

    messages: IEnumerable<TMessage>
    The collection of message instances to send.
    destination: string
    The target queue, topic, or endpoint name.
    options: MessageSendOptions?
    The send configuration tailoring headers and metadata, if specified.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating whether the batch was acknowledged.

    Type parameters: TMessage: The type of the command message payload. Exceptions: ArgumentNullException: `messages` is `null`; ArgumentException: `destination` is `null`, empty, or consists only of white-space characters

EricksonLopez.Messaging.Events#

3
class

MessagingEventPublisher

Assembly: EricksonLopez.Messaging.Events
public sealed class MessagingEventPublisher : IEventPublisher
Implements: IEventPublisher

Dispatches domain and integration events through an `IMessagePublisher`.

Members (2)

  • constructorMessagingEventPublisher
    public MessagingEventPublisher(IMessagePublisher messagePublisher, MessagingEventsOptions? options = null)

    Initializes a new instance of the `MessagingEventPublisher` class with the specified message publisher and options.

    messagePublisher: IMessagePublisher
    The message publisher implementation.
    options: MessagingEventsOptions?
    The publisher configuration options, if specified.

    Exceptions: ArgumentNullException: `messagePublisher` is `null`

  • methodPublishAsync<TEvent>
    public async ValueTask PublishAsync<TEvent>(TEvent eventInstance, CancellationToken cancellationToken = default) where TEvent : IEvent

    Inherits documentation from base type or interface.

    eventInstance: TEvent
    cancellationToken: CancellationToken

    Exceptions: ArgumentNullException: `eventInstance` is `null`; InvalidOperationException: Publishing via the underlying message transport failed and `MessagingEventsOptions.ThrowOnFailure` is `true`

class

MessagingEventsOptions

Assembly: EricksonLopez.Messaging.Events
public sealed class MessagingEventsOptions

Specifies configuration options for the messaging event publisher bridge.

Members (2)

  • propertyDestinationResolver
    public Func<Type, string?>? DestinationResolver { get; set; }

    Gets or sets a custom function to resolve destination topic or exchange names for a given event type.

  • propertyThrowOnFailure
    public bool ThrowOnFailure { get; set; }

    Gets or sets a value indicating whether an exception is thrown when publishing fails.

class

MessagingEventsServiceCollectionExtensions

Assembly: EricksonLopez.Messaging.Events
public static class MessagingEventsServiceCollectionExtensions

Provides extension methods for registering `MessagingEventPublisher` in an `IServiceCollection`.

Members (1)

  • methodAddMessagingEventPublisher
    public static IServiceCollection AddMessagingEventPublisher(this IServiceCollection services, Action<MessagingEventsOptions>? configureOptions = null)

    Registers `MessagingEventPublisher` as the `IEventPublisher` implementation in the service container.

    services: this IServiceCollection
    The service collection to configure.
    configureOptions: Action<MessagingEventsOptions>?
    The delegate to configure publisher options, if specified.

    Returns: The configured `IServiceCollection`.

    Exceptions: ArgumentNullException: `services` is `null`

EricksonLopez.Messaging.Extensions#

1
class

MessagingOptionsBuilder

Assembly: EricksonLopez.Messaging
public sealed class MessagingOptionsBuilder

Provides a fluent configuration builder for messaging middleware and options.

Members (14)

  • constructorMessagingOptionsBuilder
    public MessagingOptionsBuilder(IServiceCollection services)

    Initializes a new instance of the `MessagingOptionsBuilder` class with the specified service collection.

    services: IServiceCollection
    The service collection instance to configure.
  • methodAddCircuitBreaker
    public MessagingOptionsBuilder AddCircuitBreaker(Action<CircuitBreakerOptions>? configure = null)

    Adds circuit breaker resilience middleware to the message processing pipeline.

    configure: Action<CircuitBreakerOptions>?
    The delegate to configure circuit breaker options, if specified.

    Returns: The current `MessagingOptionsBuilder` instance.

  • methodAddDeduplication
    public MessagingOptionsBuilder AddDeduplication(Action<MessageDeduplicationOptions>? configure = null)

    Adds message deduplication middleware to prevent repeated execution of duplicate messages based on message identity.

    configure: Action<MessageDeduplicationOptions>?
    The delegate to configure deduplication options including retention duration, if specified.

    Returns: The current `MessagingOptionsBuilder` instance.

  • methodAddExceptionHandling
    public MessagingOptionsBuilder AddExceptionHandling()

    Adds exception handling middleware that catches unhandled exceptions and converts them into `Result.Result` failures, preventing raw exceptions from escaping the pipeline.

    Returns: The current `MessagingOptionsBuilder` instance.

    `ExceptionHandlingMiddleware` is already registered in the default pipeline by `AddMessaging()`. Use this method when building a custom pipeline without the defaults, or when you need to control the position of exception handling relative to other middlewares. This method is idempotent: calling it multiple times or in combination with the default pipeline will not register duplicate middleware instances. Only a single `ExceptionHandlingMiddleware` will be present in the resolved pipeline.

  • methodAddHandlerTimeout
    public MessagingOptionsBuilder AddHandlerTimeout(Action<HandlerTimeoutOptions>? configure = null)

    Adds handler execution timeout middleware to the message processing pipeline using a configuration delegate.

    configure: Action<HandlerTimeoutOptions>?
    The delegate to configure `HandlerTimeoutOptions` with custom timeout and time provider settings, if specified.

    Returns: The current `MessagingOptionsBuilder` instance.

  • methodAddHandlerTimeout
    public MessagingOptionsBuilder AddHandlerTimeout(TimeSpan timeout)

    Adds handler execution timeout middleware to the message processing pipeline using an explicit timeout duration.

    timeout: TimeSpan
    The maximum allowed execution duration per message. Must be a positive, finite duration.

    Returns: The current `MessagingOptionsBuilder` instance.

  • methodAddLogging
    public MessagingOptionsBuilder AddLogging()

    Adds structured logging middleware that records message processing events with full context correlation.

    Returns: The current `MessagingOptionsBuilder` instance.

    `LoggingMiddleware` is already registered in the default pipeline by `AddMessaging()`. Use this method when building a custom pipeline without the defaults, or when you need to control the position of logging relative to other middlewares. This method is idempotent: calling it multiple times or in combination with the default pipeline will not register duplicate middleware instances.

  • methodAddMiddleware<TMiddleware>
    public MessagingOptionsBuilder AddMiddleware<TMiddleware>() where TMiddleware : class, IMessageMiddleware

    Registers a custom middleware into the message processing pipeline.

    Returns: The current `MessagingOptionsBuilder` instance.

    Type parameters: TMiddleware: The type of middleware implementation to register.

  • methodAddRetry
    public MessagingOptionsBuilder AddRetry(Action<RetryOptions>? configure = null)

    Adds retry middleware with exponential backoff and full-jitter randomization to the message processing pipeline.

    configure: Action<RetryOptions>?
    The delegate to configure retry options including maximum attempts, initial delay, and time provider, if specified.

    Returns: The current `MessagingOptionsBuilder` instance.

  • methodAddTracing
    public MessagingOptionsBuilder AddTracing()

    Adds distributed tracing middleware that propagates and creates W3C `traceparent` spans across messaging operations.

    Returns: The current `MessagingOptionsBuilder` instance.

    `TracingMiddleware` is already registered in the default pipeline by `AddMessaging()`. Use this method when building a custom pipeline without the defaults, or when you need to control the position of tracing relative to other middlewares. This method is idempotent: calling it multiple times or in combination with the default pipeline will not register duplicate middleware instances.

  • methodAddUpcasting
    public MessagingOptionsBuilder AddUpcasting()

    Adds message schema upcasting middleware to automatically upgrade legacy message schemas.

    Returns: The current `MessagingOptionsBuilder` instance.

  • methodConfigureConsumer
    public MessagingOptionsBuilder ConfigureConsumer(Action<MessageConsumerOptions> configure)

    Configures message consumer execution options such as unhandled failure acknowledgement behavior.

    configure: Action<MessageConsumerOptions>
    The delegate to configure `MessageConsumerOptions`.

    Returns: The current `MessagingOptionsBuilder` instance.

    Exceptions: ArgumentNullException: `configure` is `null`

  • methodEnableMessageContextPooling
    public MessagingOptionsBuilder EnableMessageContextPooling(int maximumRetained = 1024)

    Enables high-performance object pooling for `MessageContext` instances to eliminate allocations during message dispatch.

    maximumRetained: int
    The maximum number of pooled message context instances to retain in memory. Defaults to 1024.

    Returns: The current `MessagingOptionsBuilder` instance.

    Exceptions: ArgumentOutOfRangeException: `maximumRetained` is less than or equal to zero

  • propertyServices
    public IServiceCollection Services { get; }

    Gets the service collection being configured.

EricksonLopez.Messaging.Generators#

1
class

MessagingIncrementalGenerator

Assembly: EricksonLopez.Messaging.Generators
public sealed class MessagingIncrementalGenerator : IIncrementalGenerator
Implements: IIncrementalGenerator

Provides an incremental source generator that discovers message handlers at compile time and generates registration code.

Members (1)

  • methodInitialize
    public void Initialize(IncrementalGeneratorInitializationContext context)

    Inherits documentation from base type or interface.

    context: IncrementalGeneratorInitializationContext

EricksonLopez.Messaging.HealthChecks#

3
class

MessagingHealthCheck

Assembly: EricksonLopez.Messaging
public sealed class MessagingHealthCheck : IHealthCheck
Implements: IHealthCheck

Provides specialized health checks distinguishing process liveness from operational transport readiness.

Members (3)

  • constructorMessagingHealthCheck
    public MessagingHealthCheck(IMessagePublisher? publisher)

    Initializes a new instance of the `MessagingHealthCheck` class with the specified message publisher. Preserves binary backward compatibility with v1.0 assemblies.

    publisher: IMessagePublisher?
    The message publisher instance to check, if registered.
  • constructorMessagingHealthCheck
    public MessagingHealthCheck(IMessagePublisher? publisher = null, IMessageTransport? transport = null, IMessageConsumer? consumer = null, IOptions<MessagingHealthCheckOptions>? options = null)

    Initializes a new instance of the `MessagingHealthCheck` class with the specified messaging dependencies.

    publisher: IMessagePublisher?
    The message publisher instance to check, if registered.
    transport: IMessageTransport?
    The message transport instance to check, if registered.
    consumer: IMessageConsumer?
    The message consumer instance to check, if registered.
    options: IOptions<MessagingHealthCheckOptions>?
    The health check configuration options, if specified.
  • methodCheckHealthAsync
    public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)

    Inherits documentation from base type or interface.

    context: HealthCheckContext
    cancellationToken: CancellationToken
enum

MessagingHealthCheckMode

Assembly: EricksonLopez.Messaging
public enum MessagingHealthCheckMode

Defines evaluation modes for messaging health checks.

Members (3)

  • fieldAuto
    Auto = 0

    Automatically infers the evaluation mode from registration tags ("live"/"liveness" vs "ready"/"readiness").

  • fieldLiveness
    Liveness = 1

    Evaluates liveness: verifies process vitality and dependency injection container registrations.

  • fieldReadiness
    Readiness = 2

    Evaluates readiness: verifies transport connectivity, consumer state, and operational readiness.

class

MessagingHealthCheckOptions

Assembly: EricksonLopez.Messaging
public sealed class MessagingHealthCheckOptions

Configuration options for messaging health checks.

Members (3)

  • propertyMode
    public MessagingHealthCheckMode Mode { get; set; }

    Gets or sets the evaluation mode. Defaults to `MessagingHealthCheckMode.Auto`.

  • propertyRequirePublisher
    public bool RequirePublisher { get; set; }

    Gets or sets whether publisher registration is required for a healthy check. Defaults to `true`.

  • propertyValidateTransportReadiness
    public bool ValidateTransportReadiness { get; set; }

    Gets or sets whether physical transport readiness is validated when available. Defaults to `true`.

EricksonLopez.Messaging.Hosting#

1
class

MessagingConsumerHostedService

Assembly: EricksonLopez.Messaging
public sealed class MessagingConsumerHostedService : BackgroundService
Inherits: BackgroundService

Provides a hosted service managing the background lifecycle, startup, and graceful shutdown of an `IMessageConsumer`.

Members (2)

  • constructorMessagingConsumerHostedService
    public MessagingConsumerHostedService(IMessageConsumer consumer, ILogger<MessagingConsumerHostedService>? logger = null)

    Initializes a new instance of the `MessagingConsumerHostedService` class with the specified consumer and logger.

    consumer: IMessageConsumer
    The message consumer lifecycle manager.
    logger: ILogger<MessagingConsumerHostedService>?
    The logger instance, if specified.

    Exceptions: ArgumentNullException: `consumer` is `null`

  • methodStopAsync
    public override async Task StopAsync(CancellationToken cancellationToken)

    Inherits documentation from base type or interface.

    cancellationToken: CancellationToken

    Executes a graceful shutdown sequence: stops accepting new messages via `IMessageConsumer.StopReceivingAsync`, drains all in-flight messages via `IMessageConsumer.DrainInFlightMessagesAsync`, then delegates to the base `BackgroundService.StopAsync` implementation.

EricksonLopez.Messaging.Idempotency#

2
class

IdempotencyStoreDeduplicationAdapter

Assembly: EricksonLopez.Messaging.Idempotency
public sealed class IdempotencyStoreDeduplicationAdapter : IMessageDeduplicationStore, IDisposable
Implements: IDisposable, IMessageDeduplicationStore

Adapts an `IIdempotencyStore` to provide distributed message deduplication conforming to `IMessageDeduplicationStore`.

Members (5)

  • constructorIdempotencyStoreDeduplicationAdapter
    public IdempotencyStoreDeduplicationAdapter(IIdempotencyStore store, IOptions<MessagingIdempotencyOptions>? options = null, ILogger<IdempotencyStoreDeduplicationAdapter>? logger = null)

    Initializes a new instance of the `IdempotencyStoreDeduplicationAdapter` class.

    store: IIdempotencyStore
    The underlying distributed idempotency store.
    options: IOptions<MessagingIdempotencyOptions>?
    The configured idempotency options.
    logger: ILogger<IdempotencyStoreDeduplicationAdapter>?
    The optional diagnostic logger.

    Exceptions: ArgumentNullException: `store` is `null`

  • constructorIdempotencyStoreDeduplicationAdapter
    public IdempotencyStoreDeduplicationAdapter(IIdempotencyStore store, MessagingIdempotencyOptions options)

    Initializes a new instance of the `IdempotencyStoreDeduplicationAdapter` class with explicit options.

    store: IIdempotencyStore
    The underlying distributed idempotency store.
    options: MessagingIdempotencyOptions
    The idempotency options.

    Exceptions: ArgumentNullException: `store` or `options` is `null`

  • methodDispose
    public void Dispose()

    Releases the resources used by the adapter.

  • methodReleaseAsync
    public async ValueTask ReleaseAsync(string messageId, CancellationToken cancellationToken = default)

    Releases the idempotency lock for the specified message identity, allowing it to be retried.

    messageId: string
    The unique identity of the message.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation.

    Exceptions: ArgumentException: `messageId` is `null`, empty, or consists only of white-space characters

  • methodTryAcquireAsync
    public async ValueTask<bool> TryAcquireAsync(string messageId, TimeSpan expiration, CancellationToken cancellationToken = default)

    Attempts to acquire an idempotency lock for the specified message identity.

    messageId: string
    The unique identity of the message.
    expiration: TimeSpan
    The maximum duration to retain the deduplication state.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains `true` if the lock was successfully acquired; otherwise, `false` if the message is a duplicate.

    Exceptions: ArgumentException: `messageId` is `null`, empty, or consists only of white-space characters

class

MessagingIdempotencyOptions

Assembly: EricksonLopez.Messaging.Idempotency
public sealed class MessagingIdempotencyOptions

Specifies configuration options for distributed idempotency and message deduplication.

Members (9)

  • methodWithFingerprintProvider
    public MessagingIdempotencyOptions WithFingerprintProvider(Func<string, string>? fingerprintProvider)

    Sets the fingerprint provider fluently.

    fingerprintProvider: Func<string, string>?
    The fingerprint provider delegate.

    Returns: This options instance for fluent chaining.

  • methodWithRetentionBuffer
    public MessagingIdempotencyOptions WithRetentionBuffer(TimeSpan retentionBuffer)

    Sets the retention buffer fluently.

    retentionBuffer: TimeSpan
    The retention buffer duration.

    Returns: This options instance for fluent chaining.

  • methodWithScope
    public MessagingIdempotencyOptions WithScope(string scope)

    Sets the scope fluently.

    scope: string
    The scope string.

    Returns: This options instance for fluent chaining.

  • methodWithTenantId
    public MessagingIdempotencyOptions WithTenantId(Guid? tenantId)

    Sets the tenant identifier fluently from a `Guid`.

    tenantId: Guid?
    The tenant identifier.

    Returns: This options instance for fluent chaining.

  • propertyFingerprintProvider
    public Func<string, string>? FingerprintProvider { get; set; }

    Gets or sets an optional delegate used to compute the fingerprint for a given message identifier. When `null`, the message identifier itself is used as the fingerprint.

  • propertyRetentionBuffer
    public TimeSpan RetentionBuffer { get; set; }

    Gets or sets an additional retention buffer added to the lease duration to prevent premature record cleanup. Defaults to `TimeSpan.Zero`.

  • propertyScope
    public string Scope { get; set; }

    Gets or sets the scope namespace used when claiming idempotency leases in the underlying store. Defaults to `"messaging.deduplication"`.

  • propertyTenantId
    public Guid? TenantId { get; set; }

    Gets or sets the optional tenant identifier for multi-tenant isolation. Defaults to `null` (mapped to `Guid.Empty`).

  • fieldDefaultScope
    public const string DefaultScope

    Specifies the default scope for messaging deduplication claims.

EricksonLopez.Messaging.Middleware#

18
class

CircuitBreakerMiddleware

Assembly: EricksonLopez.Messaging
public sealed class CircuitBreakerMiddleware : IMessageMiddleware
Implements: IMessageMiddleware

Provides circuit breaker resilience middleware to halt message processing when failure thresholds are breached.

Remarks:

Implements a three-state machine: `Closed` (normal), `Open` (fast-fail), and `HalfOpen` (recovery probe). Failures are counted within a sliding observation window defined by `CircuitBreakerOptions.SamplingDuration`. If the time elapsed since the first recorded consecutive failure exceeds `CircuitBreakerOptions.SamplingDuration`, the failure counter is reset before counting the new failure, preventing stale failures from accumulating across long idle periods. A successful execution always resets the failure counter to zero.

Members (3)

  • constructorCircuitBreakerMiddleware
    public CircuitBreakerMiddleware(CircuitBreakerOptions options, ILogger<CircuitBreakerMiddleware>? logger = null)

    Initializes a new instance of the `CircuitBreakerMiddleware` class with explicit options.

    options: CircuitBreakerOptions
    The circuit breaker configuration options.
    logger: ILogger<CircuitBreakerMiddleware>?
    The logger instance, if specified.
  • constructorCircuitBreakerMiddleware
    public CircuitBreakerMiddleware(IOptions<CircuitBreakerOptions>? options = null, ILogger<CircuitBreakerMiddleware>? logger = null)

    Initializes a new instance of the `CircuitBreakerMiddleware` class with the specified options and logger.

    options: IOptions<CircuitBreakerOptions>?
    The circuit breaker configuration options.
    logger: ILogger<CircuitBreakerMiddleware>?
    The logger instance, if specified.
  • methodInvokeAsync
    public async ValueTask<Result> InvokeAsync(MessageContext context, MessageExecutionDelegate next, CancellationToken cancellationToken)

    Invokes the middleware logic and continues execution along the pipeline.

    context: MessageContext
    The ambient message execution context.
    next: MessageExecutionDelegate
    The delegate representing the next step in the pipeline.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the execution outcome.

    Exceptions: ArgumentNullException: `context` or `next` is `null`

class

CircuitBreakerOptions

Assembly: EricksonLopez.Messaging
public sealed class CircuitBreakerOptions

Specifies configuration options for `CircuitBreakerMiddleware`.

Members (5)

  • propertyBreakDuration
    public TimeSpan BreakDuration { get; set; }

    Gets or sets the duration the circuit remains open before transitioning to the half-open state.

  • propertyFailureFilter
    public Func<Error, bool>? FailureFilter { get; set; }

    Gets or sets an optional predicate to determine whether an error should be considered a failure for the circuit breaker. When `null`, all `Result` failures are treated as failures.

  • propertyFailureThreshold
    public int FailureThreshold { get; set; }

    Gets or sets the consecutive failure count threshold required to trip the circuit open.

  • propertySamplingDuration
    public TimeSpan SamplingDuration { get; set; }

    Gets or sets the observation window within which consecutive failures are counted toward the threshold.

    When a new failure is recorded, if the time elapsed since the first consecutive failure in the current sequence exceeds `SamplingDuration`, the failure counter is reset before incrementing. This prevents failures that are spread far apart in time from accumulating toward `FailureThreshold`. Defaults to 30 seconds.

  • propertyTimeProvider
    public TimeProvider? TimeProvider { get; set; }

    Gets or sets an optional time provider override for elapsed-time calculations.

    When `null`, `TimeProvider.System` is used. Override this property in tests to control time progression.

class

ExceptionHandlingMiddleware

Assembly: EricksonLopez.Messaging
public sealed class ExceptionHandlingMiddleware : IMessageMiddleware
Implements: IMessageMiddleware

Provides safety middleware that catches unhandled exceptions during handler execution and converts them into functional `Result` failures.

Remarks:

`OperationCanceledException` thrown when the pipeline's `CancellationToken` is already cancelled is caught and returned as `Result.Failure(Error.Failure("Messaging.Cancelled", ...))`. This prevents cancellation from appearing as an unexpected error in consumer error counters. All other exceptions are caught and returned as `Result.Failure(Error.Unexpected("Messaging.UnhandledException", ...))`. The exception message is included in the error description. No stack trace is captured in the Result; the exception is available via logs produced by `LoggingMiddleware` if it is also in the pipeline.

Members (1)

  • methodInvokeAsync
    public async ValueTask<Result> InvokeAsync(MessageContext context, MessageExecutionDelegate next, CancellationToken cancellationToken)

    Invokes the middleware logic and continues execution along the pipeline.

    context: MessageContext
    The ambient message execution context.
    next: MessageExecutionDelegate
    The delegate representing the next step in the pipeline.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the execution outcome.

class

HandlerTimeoutMiddleware

Assembly: EricksonLopez.Messaging
public sealed class HandlerTimeoutMiddleware : IMessageMiddleware
Implements: IMessageMiddleware

Provides timeout middleware enforcing maximum execution limits on message handler invocations via linked cancellation tokens.

Members (3)

  • constructorHandlerTimeoutMiddleware
    public HandlerTimeoutMiddleware(HandlerTimeoutOptions options, ILogger<HandlerTimeoutMiddleware>? logger = null)

    Initializes a new instance of the `HandlerTimeoutMiddleware` class with explicit options.

    options: HandlerTimeoutOptions
    The timeout configuration options.
    logger: ILogger<HandlerTimeoutMiddleware>?
    The logger instance, if specified.
  • constructorHandlerTimeoutMiddleware
    public HandlerTimeoutMiddleware(IOptions<HandlerTimeoutOptions>? options = null, ILogger<HandlerTimeoutMiddleware>? logger = null)

    Initializes a new instance of the `HandlerTimeoutMiddleware` class with the specified options and logger.

    options: IOptions<HandlerTimeoutOptions>?
    The timeout configuration options.
    logger: ILogger<HandlerTimeoutMiddleware>?
    The logger instance, if specified.
  • methodInvokeAsync
    public async ValueTask<Result> InvokeAsync(MessageContext context, MessageExecutionDelegate next, CancellationToken cancellationToken)

    Invokes the middleware logic and continues execution along the pipeline.

    context: MessageContext
    The ambient message execution context.
    next: MessageExecutionDelegate
    The delegate representing the next step in the pipeline.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the execution outcome.

    Exceptions: ArgumentNullException: `context` or `next` is `null`

class

HandlerTimeoutOptions

Assembly: EricksonLopez.Messaging
public sealed class HandlerTimeoutOptions

Specifies configuration options for `HandlerTimeoutMiddleware`.

Members (2)

  • propertyTimeProvider
    public TimeProvider? TimeProvider { get; set; }

    Gets or sets an optional time provider override for timeout cancellation scheduling.

    When `null`, `TimeProvider.System` is used. Override this property in tests to control time progression.

  • propertyTimeout
    public TimeSpan Timeout { get; set; }

    Gets or sets the maximum execution duration allowed for message processing before cancelling the operation.

    Defaults to 30 seconds. Must be a positive, finite duration when set explicitly via `MessagingOptionsBuilder.AddHandlerTimeout(TimeSpan)`.

interface

IMessageMiddleware

Assembly: EricksonLopez.Messaging
public interface IMessageMiddleware

Defines an interceptor middleware component in the message consumption pipeline.

Members (1)

  • methodInvokeAsync
    ValueTask<Result> InvokeAsync(MessageContext context, MessageExecutionDelegate next, CancellationToken cancellationToken)

    Invokes the middleware logic and continues execution along the pipeline.

    context: MessageContext
    The ambient message execution context.
    next: MessageExecutionDelegate
    The delegate representing the next step in the pipeline.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the execution outcome.

interface

IMessageUpcasterInvoker

Assembly: EricksonLopez.Messaging
public interface IMessageUpcasterInvoker

Defines non-generic invocation of registered message upcasters during pipeline execution.

Members (3)

  • methodUpcast
    object Upcast(object message, TransportMessageMetadata metadata, IServiceProvider serviceProvider)

    Transforms the source message instance to its upgraded schema target.

    message: object
    The source message instance.
    metadata: TransportMessageMetadata
    The message metadata.
    serviceProvider: IServiceProvider
    The service provider for dependency resolution.

    Returns: The upgraded message instance.

  • propertySourceType
    Type SourceType { get; }

    Gets the source message type from which this upcaster transforms.

  • propertyTargetType
    Type TargetType { get; }

    Gets the target message type to which this upcaster transforms.

class

InMemoryMessageDeduplicationStore

Assembly: EricksonLopez.Messaging
public sealed class InMemoryMessageDeduplicationStore : IMessageDeduplicationStore, IDisposable
Implements: IDisposable, IMessageDeduplicationStore

Provides a high-performance in-memory, thread-safe implementation of `IMessageDeduplicationStore` with bounded capacity and Least Recently Used (LRU) eviction.

Members (11)

  • constructorInMemoryMessageDeduplicationStore
    public InMemoryMessageDeduplicationStore()

    Initializes a new instance with default capacity (100,000) and system time provider.

  • constructorInMemoryMessageDeduplicationStore
    public InMemoryMessageDeduplicationStore(IOptions<MessageDeduplicationOptions>? options, TimeProvider? timeProvider = null)

    Initializes a new instance with custom options from dependency injection.

    options: IOptions<MessageDeduplicationOptions>?
    The configured deduplication options.
    timeProvider: TimeProvider?
    The optional time provider instance.
  • constructorInMemoryMessageDeduplicationStore
    public InMemoryMessageDeduplicationStore(int maxCapacity)

    Initializes a new instance with custom maximum capacity.

    maxCapacity: int
    The maximum capacity before LRU eviction occurs.
  • constructorInMemoryMessageDeduplicationStore
    public InMemoryMessageDeduplicationStore(int maxCapacity, TimeProvider? timeProvider)

    Initializes a new instance of the `InMemoryMessageDeduplicationStore` class with custom capacity and time provider.

    maxCapacity: int
    The maximum number of entries before LRU eviction triggers.
    timeProvider: TimeProvider?
    The time provider instance.
  • constructorInMemoryMessageDeduplicationStore
    public InMemoryMessageDeduplicationStore(TimeProvider? timeProvider)

    Initializes a new instance with a custom time provider and default capacity.

    timeProvider: TimeProvider?
    The time provider instance.
  • methodDispose
    public void Dispose()

    Releases the resources used by this instance.

  • methodReleaseAsync
    public ValueTask ReleaseAsync(string messageId, CancellationToken cancellationToken = default)

    Releases the idempotency lock for the specified message identity, allowing it to be retried.

    messageId: string
    The unique identity of the message.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation.

    Exceptions: ArgumentException: `messageId` is `null`, empty, or consists only of white-space characters

  • methodTryAcquireAsync
    public ValueTask<bool> TryAcquireAsync(string messageId, TimeSpan expiration, CancellationToken cancellationToken = default)

    Attempts to acquire an idempotency lock for the specified message identity.

    messageId: string
    The unique identity of the message.
    expiration: TimeSpan
    The maximum duration to retain the deduplication state.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains `true` if the lock was successfully acquired; otherwise, `false` if the message is a duplicate.

    Exceptions: ArgumentException: `messageId` is `null`, empty, or consists only of white-space characters

  • propertyCount
    public int Count { get; }

    Gets the number of entries currently stored.

  • propertyMaxCapacity
    public int MaxCapacity { get; }

    Gets the maximum capacity of the in-memory store before LRU eviction occurs.

  • fieldDefaultMaxCapacity
    public const int DefaultMaxCapacity

    Specifies the default maximum number of entries (100,000) retained in memory before LRU eviction occurs.

class

LoggingMiddleware

Assembly: EricksonLopez.Messaging
public sealed class LoggingMiddleware : IMessageMiddleware
Implements: IMessageMiddleware

Provides structured logging middleware for the message processing pipeline.

Remarks:

When an exception propagates from the next middleware or handler, `LoggingMiddleware` logs the error at `Error` level and then re-throws the exception. It does not convert exceptions into `Result.Result` failures. If unhandled exceptions must be captured as functional results, ensure `ExceptionHandlingMiddleware` is registered earlier in the pipeline (before `LoggingMiddleware`). Both middlewares are part of the default pipeline registered by `AddMessaging()`.

Members (2)

  • constructorLoggingMiddleware
    public LoggingMiddleware(ILogger<LoggingMiddleware>? logger = null)

    Initializes a new instance of the `LoggingMiddleware` class with the specified logger.

    logger: ILogger<LoggingMiddleware>?
    The logger instance, if specified.
  • methodInvokeAsync
    public async ValueTask<Result> InvokeAsync(MessageContext context, MessageExecutionDelegate next, CancellationToken cancellationToken)

    Invokes the middleware logic and continues execution along the pipeline.

    context: MessageContext
    The ambient message execution context.
    next: MessageExecutionDelegate
    The delegate representing the next step in the pipeline.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the execution outcome.

class

MessageDeduplicationMiddleware

Assembly: EricksonLopez.Messaging
public sealed class MessageDeduplicationMiddleware : IMessageMiddleware
Implements: IMessageMiddleware

Intercepts incoming messages to detect and suppress duplicate executions based on message identity.

Members (2)

  • constructorMessageDeduplicationMiddleware
    public MessageDeduplicationMiddleware(IMessageDeduplicationStore store, IOptions<MessageDeduplicationOptions>? options = null, ILogger<MessageDeduplicationMiddleware>? logger = null)

    Initializes a new instance of the `MessageDeduplicationMiddleware` class.

    store: IMessageDeduplicationStore
    The deduplication state store.
    options: IOptions<MessageDeduplicationOptions>?
    The deduplication options.
    logger: ILogger<MessageDeduplicationMiddleware>?
    The diagnostic logger.

    Exceptions: ArgumentNullException: `store` is `null`

  • methodInvokeAsync
    public async ValueTask<Result> InvokeAsync(MessageContext context, MessageExecutionDelegate next, CancellationToken cancellationToken)

    Invokes the middleware logic and continues execution along the pipeline.

    context: MessageContext
    The ambient message execution context.
    next: MessageExecutionDelegate
    The delegate representing the next step in the pipeline.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the execution outcome.

    Exceptions: ArgumentNullException: `context` or `next` is `null`

class

MessageDeduplicationOptions

Assembly: EricksonLopez.Messaging
public sealed class MessageDeduplicationOptions

Configures message deduplication behavior in the message processing pipeline.

Members (3)

  • propertyEnabled
    public bool Enabled { get; set; }

    Gets or sets a value indicating whether message deduplication is actively enforced.

  • propertyExpiration
    public TimeSpan Expiration { get; set; }

    Gets or sets the duration for which processed message identifiers are retained to prevent duplicate handling. The default is 24 hours.

  • propertyMaxCapacity
    public int MaxCapacity { get; set; }

    Gets or sets the maximum number of message identifiers retained in memory before LRU eviction occurs. Default is 100,000.

delegate

MessageExecutionDelegate

Assembly: EricksonLopez.Messaging
public delegate ValueTask<Result> MessageExecutionDelegate(MessageContext context, CancellationToken cancellationToken)
Inherits: System.MulticastDelegate

Encapsulates an asynchronous continuation step in the message processing middleware pipeline.

Members (0)

This type declares 0 public members (e.g. marker interface or empty enum/record).

class

MessageUpcasterInvoker<TOld, TNew, TUpcaster>

Assembly: EricksonLopez.Messaging
public sealed class MessageUpcasterInvoker<TOld, TNew, TUpcaster> : IMessageUpcasterInvoker where TOld : class, IMessage where TNew : class, IMessage where TUpcaster : class, IMessageUpcaster<TOld, TNew>
Implements: IMessageUpcasterInvoker

Adapts `IMessageUpcaster<TOldMessage, TNewMessage>` implementations to `IMessageUpcasterInvoker`.

Remarks:

Type parameters: TOld: The source message type.; TNew: The target upgraded message type.; TUpcaster: The type of upcaster implementation.

Members (3)

  • methodUpcast
    public object Upcast(object message, TransportMessageMetadata metadata, IServiceProvider serviceProvider)

    Transforms the source message instance to its upgraded schema target.

    message: object
    The source message instance.
    metadata: TransportMessageMetadata
    The message metadata.
    serviceProvider: IServiceProvider
    The service provider for dependency resolution.

    Returns: The upgraded message instance.

  • propertySourceType
    public Type SourceType { get; }

    Gets the source message type from which this upcaster transforms.

  • propertyTargetType
    public Type TargetType { get; }

    Gets the target message type to which this upcaster transforms.

class

MessageUpcastingMiddleware

Assembly: EricksonLopez.Messaging
public sealed class MessageUpcastingMiddleware : IMessageMiddleware
Implements: IMessageMiddleware

Provides middleware that detects legacy message schemas and applies registered upcasters to migrate payloads to the current contract version.

Members (2)

  • constructorMessageUpcastingMiddleware
    public MessageUpcastingMiddleware(IEnumerable<IMessageUpcasterInvoker> upcasters, ILogger<MessageUpcastingMiddleware>? logger = null)

    Initializes a new instance of the `MessageUpcastingMiddleware` class with the specified upcasters and logger.

    upcasters: IEnumerable<IMessageUpcasterInvoker>
    The collection of registered message upcaster invokers.
    logger: ILogger<MessageUpcastingMiddleware>?
    The logger instance, if specified.
  • methodInvokeAsync
    public async ValueTask<Result> InvokeAsync(MessageContext context, MessageExecutionDelegate next, CancellationToken cancellationToken)

    Invokes the middleware logic and continues execution along the pipeline.

    context: MessageContext
    The ambient message execution context.
    next: MessageExecutionDelegate
    The delegate representing the next step in the pipeline.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the execution outcome.

    Exceptions: ArgumentNullException: `context` or `next` is `null`

class

MiddlewarePipeline

Assembly: EricksonLopez.Messaging
public sealed class MiddlewarePipeline

Encapsulates a pipeline executor chaining registered middlewares and the terminal handler invocation.

Members (3)

  • constructorMiddlewarePipeline
    public MiddlewarePipeline(IEnumerable<IMessageMiddleware>? middlewares = null)

    Initializes a new instance of the `MiddlewarePipeline` class with the specified middlewares.

    middlewares: IEnumerable<IMessageMiddleware>?
    The collection of middleware components to include in the pipeline.
  • methodBuildChain
    public MessageExecutionDelegate BuildChain(MessageExecutionDelegate terminalHandler)

    Composes the middleware chain ending with the specified terminal handler. This builds and returns a pre-chained `MessageExecutionDelegate` that can be cached and executed repeatedly on hot dispatch paths with zero delegate or closure allocations.

    terminalHandler: MessageExecutionDelegate
    The terminal handler delegate to execute at the end of the pipeline.

    Returns: The composed delegate pipeline ready for zero-allocation execution.

    Exceptions: ArgumentNullException: `terminalHandler` is `null`

  • methodExecuteAsync
    public ValueTask<Result> ExecuteAsync(MessageContext context, MessageExecutionDelegate terminalHandler, CancellationToken cancellationToken = default)

    Executes the middleware pipeline terminating at the specified terminal handler delegate.

    context: MessageContext
    The ambient message execution context.
    terminalHandler: MessageExecutionDelegate
    The terminal handler delegate to execute at the end of the pipeline.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the execution outcome.

    For pipelines with 0, 1, 2, or 3 registered middlewares, the chain is executed using an inlined, non-recursive delegate composition that avoids recursive closure allocations on the hot dispatch path. For pipelines with 4 or more middlewares, execution falls back to `InvokeStepAsync`. Exceptions: ArgumentNullException: `context` or `terminalHandler` is `null`; OperationCanceledException: `cancellationToken` is cancelled before pipeline execution begins

class

RetryMiddleware

Assembly: EricksonLopez.Messaging
public sealed class RetryMiddleware : IMessageMiddleware
Implements: IMessageMiddleware

Provides retry middleware with exponential backoff and full-jitter randomization for transient processing failures.

Remarks:

Implements the "full jitter" exponential backoff strategy: `delay = Random(0, initialDelay * 2^attempt)`. This prevents thundering-herd scenarios where many consumers retry simultaneously after a shared downstream failure. If cancellation is requested at any point, the retry loop exits immediately without scheduling further delays. The last retry attempt (when maximum retry attempts have been exhausted) is allowed to propagate exceptions and failures to the calling pipeline.

Members (3)

  • constructorRetryMiddleware
    public RetryMiddleware(RetryOptions options)

    Initializes a new instance of the `RetryMiddleware` class with the specified `RetryOptions`.

    options: RetryOptions
    The configuration options for the retry logic.

    Due to C# constructor chaining semantics, the `this(...)` delegation executes before the constructor body. If `options` is `null`, each property access uses `null-coalescing` operators to fall back to safe defaults during chaining. `ArgumentNullException.ThrowIfNull` then validates and throws in the constructor body, ensuring the exception is correctly propagated without leaving the object in a corrupted state — the chaining is fully defensive. Exceptions: ArgumentNullException: `options` is `null`

  • constructorRetryMiddleware
    public RetryMiddleware(int maxRetries = 3, TimeSpan? initialDelay = null, TimeProvider? timeProvider = null, TimeSpan? maxDelay = null, Func<Error, bool>? shouldRetry = null)

    Initializes a new instance of the `RetryMiddleware` class with the specified retry parameters.

    maxRetries: int
    The maximum number of retry attempts before the last attempt is allowed to propagate. Values less than zero are clamped to zero, meaning no retries occur.
    initialDelay: TimeSpan?
    The base delay used as the ceiling for full-jitter calculation. The ceiling doubles on each attempt. Defaults to 100 milliseconds when `null`.
    timeProvider: TimeProvider?
    An optional time provider used for delay scheduling. When `null`, `TimeProvider.System` is used.
    maxDelay: TimeSpan?
    The maximum allowable delay ceiling between attempts. Defaults to 1 minute when `null`.
    shouldRetry: Func<Error, bool>?
    An optional predicate to determine whether a failed `Result` should be retried.
  • methodInvokeAsync
    public async ValueTask<Result> InvokeAsync(MessageContext context, MessageExecutionDelegate next, CancellationToken cancellationToken)

    Invokes the middleware logic and continues execution along the pipeline.

    context: MessageContext
    The ambient message execution context.
    next: MessageExecutionDelegate
    The delegate representing the next step in the pipeline.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the execution outcome.

class

RetryOptions

Assembly: EricksonLopez.Messaging
public sealed class RetryOptions

Specifies configuration options for `RetryMiddleware`.

Members (5)

  • propertyInitialDelay
    public TimeSpan InitialDelay { get; set; }

    Gets or sets the base delay applied before the first retry attempt. Subsequent delays are calculated using an exponential backoff formula with full-jitter randomization.

    Defaults to 100 milliseconds.

  • propertyMaxDelay
    public TimeSpan MaxDelay { get; set; }

    Gets or sets the maximum delay cap applied to any retry attempt.

    Defaults to 1 minute.

  • propertyMaxRetries
    public int MaxRetries { get; set; }

    Gets or sets the maximum number of retry attempts before the final attempt is allowed to propagate. Values less than zero are clamped to zero, meaning no retries occur.

  • propertyShouldRetry
    public Func<Error, bool>? ShouldRetry { get; set; }

    Gets or sets an optional predicate to determine whether a failed `Result` should be retried. When `null`, all non-successful outcomes are retried.

  • propertyTimeProvider
    public TimeProvider? TimeProvider { get; set; }

    Gets or sets an optional time provider override for delay scheduling.

    When `null`, `TimeProvider.System` is used. Override this property in tests to control time progression.

class

TracingMiddleware

Assembly: EricksonLopez.Messaging
public sealed class TracingMiddleware : IMessageMiddleware
Implements: IMessageMiddleware

Provides OpenTelemetry distributed tracing and metrics middleware for message processing.

Members (1)

  • methodInvokeAsync
    public async ValueTask<Result> InvokeAsync(MessageContext context, MessageExecutionDelegate next, CancellationToken cancellationToken)

    Invokes the middleware logic and continues execution along the pipeline.

    context: MessageContext
    The ambient message execution context.
    next: MessageExecutionDelegate
    The delegate representing the next step in the pipeline.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the execution outcome.

EricksonLopez.Messaging.Serialization#

2
class

MessagingJsonContext

Assembly: EricksonLopez.Messaging
public sealed partial class MessagingJsonContext : JsonSerializerContext
Inherits: JsonSerializerContext

Provides a source-generated `JsonSerializerContext` enabling Native AOT serialization for messaging metadata types.

Members (0)

This type declares 0 public members (e.g. marker interface or empty enum/record).

class

NativeAotJsonSerializer

Assembly: EricksonLopez.Messaging
public sealed class NativeAotJsonSerializer : IMessageSerializer
Implements: IMessageSerializer

Provides JSON serialization and deserialization supporting Native AOT through `IJsonTypeInfoResolver` and `JsonSerializerOptions`.

Members (9)

  • constructorNativeAotJsonSerializer
    public NativeAotJsonSerializer()

    Initializes a new instance of the `NativeAotJsonSerializer` class with default Native AOT source-generated metadata contexts.

  • constructorNativeAotJsonSerializer
    public NativeAotJsonSerializer(IJsonTypeInfoResolver resolver)

    Initializes a new instance of the `NativeAotJsonSerializer` class with the specified type info resolver.

    resolver: IJsonTypeInfoResolver
    The source-generated type info resolver.
  • constructorNativeAotJsonSerializer
    public NativeAotJsonSerializer(IJsonTypeInfoResolver? resolver, IOptions<JsonSerializerOptions>? options)

    Initializes a new instance of the `NativeAotJsonSerializer` class with the specified resolver and options.

    resolver: IJsonTypeInfoResolver?
    The source-generated type info resolver, if specified.
    options: IOptions<JsonSerializerOptions>?
    The JSON serializer options from dependency injection, if specified.
  • constructorNativeAotJsonSerializer
    public NativeAotJsonSerializer(JsonSerializerOptions? options)

    Initializes a new instance of the `NativeAotJsonSerializer` class with the specified serializer options.

    options: JsonSerializerOptions?
    The JSON serializer options configured with source-generated contexts, if specified.
  • methodDeserialize
    public object Deserialize(ReadOnlyMemory<byte> bytes, Type messageType)

    Deserializes binary payload data into an object instance of the specified runtime type.

    bytes: ReadOnlyMemory<byte>
    The raw binary payload segment.
    messageType: Type
    The expected target runtime type.

    Returns: The deserialized message instance.

    Exceptions: ArgumentNullException: `messageType` is `null`; InvalidOperationException: `bytes` is empty, or deserialization produced a `null` value for `messageType`

  • methodDeserialize<T>
    public T Deserialize<T>(ReadOnlyMemory<byte> bytes)

    Deserializes binary payload data into a strongly-typed message instance.

    bytes: ReadOnlyMemory<byte>
    The raw binary payload segment.

    Returns: The deserialized message instance.

    Type parameters: T: The expected message type. Exceptions: InvalidOperationException: `bytes` is empty, or deserialization produced a `null` value for `T`

  • methodSerialize<T>
    public ReadOnlyMemory<byte> Serialize<T>(T message) where T : notnull

    Serializes a strongly-typed message payload into an immutable memory segment.

    message: T
    The message instance to serialize.

    Returns: A `ReadOnlyMemory<T>` containing the serialized payload bytes.

    Type parameters: T: The message payload type.

  • methodSerialize<T>
    public void Serialize<T>(T message, IBufferWriter<byte> writer) where T : notnull

    Serializes a strongly-typed message payload directly into a buffer writer.

    message: T
    The message instance to serialize.
    writer: IBufferWriter<byte>
    The target buffer writer receiving the encoded bytes.

    Type parameters: T: The message payload type. Exceptions: ArgumentNullException: `writer` is `null`

  • propertyContentType
    public string ContentType { get; }

    Gets the media content type identifier associated with this serializer (e.g., `application/json`).

EricksonLopez.Messaging.Testing#

5
record

ConsumedMessage

Assembly: EricksonLopez.Messaging.Testing
public sealed record ConsumedMessage(string Destination, ReadOnlyMemory<byte> Payload, EricksonLopez.Messaging.Contracts.TransportMessageMetadata Metadata, bool Succeeded)

Represents a message received and processed by a subscription handler during test execution.

Members (5)

  • constructorConsumedMessage
    public ConsumedMessage(string Destination, ReadOnlyMemory<byte> Payload, EricksonLopez.Messaging.Contracts.TransportMessageMetadata Metadata, bool Succeeded)

    Initializes a new instance of ConsumedMessage.

    Destination: string
    The destination queue, topic, or exchange name.
    Payload: ReadOnlyMemory<byte>
    The raw serialized payload bytes.
    Metadata: EricksonLopez.Messaging.Contracts.TransportMessageMetadata
    The message metadata headers.
    Succeeded: bool
    A value indicating whether the handler acknowledged the message successfully.
  • propertyDestination
    public string Destination { get; init; }

    The destination queue, topic, or exchange name.

  • propertyMetadata
    public EricksonLopez.Messaging.Contracts.TransportMessageMetadata Metadata { get; init; }

    The message metadata headers.

  • propertyPayload
    public ReadOnlyMemory<byte> Payload { get; init; }

    The raw serialized payload bytes.

  • propertySucceeded
    public bool Succeeded { get; init; }

    A value indicating whether the handler acknowledged the message successfully.

class

ConsumedMessageList

Assembly: EricksonLopez.Messaging.Testing
public sealed class ConsumedMessageList : IReadOnlyList<ConsumedMessage>
Implements: IReadOnlyList<ConsumedMessage>

Represents a collection of messages consumed by subscription handlers during test execution.

Members (6)

  • methodAnySucceeded
    public bool AnySucceeded(string messageType)

    Determines whether any consumed message with the specified type was acknowledged successfully.

    messageType: string
    The message type identifier to evaluate.

    Returns: `true` if at least one matching message succeeded; otherwise, `false`.

  • methodContains
    public bool Contains(string messageType)

    Determines whether any consumed message matches the specified message type.

    messageType: string
    The message type identifier to locate.

    Returns: `true` if a matching message was consumed; otherwise, `false`.

  • methodGetEnumerator
    public IEnumerator<ConsumedMessage> GetEnumerator()

    Inherits documentation from base type or interface.

  • methodOfType
    public IEnumerable<ConsumedMessage> OfType(string messageType)

    Filters the consumed messages by the specified message type.

    messageType: string
    The message type identifier to filter by.

    Returns: An enumerable collection of matching consumed messages.

  • propertyCount
    public int Count { get; }

    Gets the number of consumed messages in the collection.

  • propertythis[int index]
    public ConsumedMessage this[int index] { get; }

    Gets the consumed message at the specified index.

    index: int
    The zero-based index of the message to get.

    Returns: The consumed message at the specified index.

class

InMemoryTestHarness

Assembly: EricksonLopez.Messaging.Testing
public sealed class InMemoryTestHarness : IMessageTransport
Implements: IMessageTransport

Provides an in-memory transport harness that records published and consumed messages for unit testing assertions.

Remarks:

The harness records all messages passed to `PublishRawAsync` in `PublishedMessages`. When `SubscribeAsync` is called, the harness immediately invokes the provided handler delegate and records the outcome (Ack or non-Ack) in `ConsumedMessages`. This design allows straightforward synchronous-style unit tests against the transport layer without requiring a running consumer hosted service.

Members (7)

  • methodDisposeAsync
    public ValueTask DisposeAsync()

    Asynchronously releases the resources used by this instance.

    Returns: A value task representing the asynchronous disposal operation.

  • methodPublishRawAsync
    public ValueTask<global::EricksonLopez.Result.Result> PublishRawAsync(string destination, ReadOnlyMemory<byte> payload, TransportMessageMetadata metadata, CancellationToken cancellationToken = default)

    Publishes a raw serialized envelope to the specified broker destination.

    destination: string
    The target topic, queue, or exchange.
    payload: ReadOnlyMemory<byte>
    The raw serialized payload bytes.
    metadata: TransportMessageMetadata
    The associated metadata headers.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the transport acknowledgement outcome.

  • methodSubscribeAsync
    public async ValueTask<global::EricksonLopez.Result.Result> SubscribeAsync(string destination, Func<ReadOnlyMemory<byte>, TransportMessageMetadata, CancellationToken, ValueTask<TransportAckResult>> messageHandler, TransportSubscriptionOptions options, CancellationToken cancellationToken = default)

    Starts consuming messages from the specified destination using the provided callback.

    destination: string
    The destination queue or topic name.
    messageHandler: Func<ReadOnlyMemory<byte>, TransportMessageMetadata, CancellationToken, ValueTask<TransportAckResult>>
    The callback invoked for each received message packet.
    options: TransportSubscriptionOptions
    The subscription concurrency and prefetch options.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the subscription outcome.

    Unlike production transports, the test harness immediately invokes `messageHandler` for every message currently in the published bag that targets `destination`. This enables synchronous test verification without an event loop. The Ack/Nack result is recorded in `ConsumedMessages`. Important: Messages published after this call returns are not automatically delivered to the handler. To test publish-then-consume flows, publish messages first and then call `SubscribeAsync`, or use `WaitUntilConsumedAsync` after triggering consumption.

  • methodWaitUntilConsumedAsync
    public async ValueTask<bool> WaitUntilConsumedAsync(string messageType, TimeSpan timeout, CancellationToken cancellationToken = default)

    Waits asynchronously until at least one message of the specified type has been consumed by a subscription handler or the timeout expires.

    messageType: string
    The message type identifier to wait for.
    timeout: TimeSpan
    The maximum duration to wait before timing out.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains `true` if the message was consumed within the timeout; otherwise, `false`.

  • methodWaitUntilPublishedAsync
    public async ValueTask<bool> WaitUntilPublishedAsync(string messageType, TimeSpan timeout, CancellationToken cancellationToken = default)

    Waits asynchronously until at least one message of the specified type has been published or the timeout expires.

    messageType: string
    The message type identifier to wait for.
    timeout: TimeSpan
    The maximum duration to wait before timing out.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains `true` if the message was published within the timeout; otherwise, `false`.

  • propertyConsumedMessages
    public ConsumedMessageList ConsumedMessages { get; }

    Gets the snapshot of all messages delivered to subscription handlers through this test harness.

  • propertyPublishedMessages
    public PublishedMessageList PublishedMessages { get; }

    Gets the snapshot of all messages published through this test harness.

record

PublishedMessage

Assembly: EricksonLopez.Messaging.Testing
public sealed record PublishedMessage(string Destination, ReadOnlyMemory<byte> Payload, TransportMessageMetadata Metadata)

Represents a message published through `InMemoryTestHarness` during test execution.

Members (4)

  • constructorPublishedMessage
    public PublishedMessage(string Destination, ReadOnlyMemory<byte> Payload, TransportMessageMetadata Metadata)

    Initializes a new instance of PublishedMessage.

    Destination: string
    The target queue, topic, or exchange name.
    Payload: ReadOnlyMemory<byte>
    The raw serialized payload bytes.
    Metadata: TransportMessageMetadata
    The message metadata headers.
  • propertyDestination
    public string Destination { get; init; }

    The target queue, topic, or exchange name.

  • propertyMetadata
    public TransportMessageMetadata Metadata { get; init; }

    The message metadata headers.

  • propertyPayload
    public ReadOnlyMemory<byte> Payload { get; init; }

    The raw serialized payload bytes.

class

PublishedMessageList

Assembly: EricksonLopez.Messaging.Testing
public sealed class PublishedMessageList : IReadOnlyList<PublishedMessage>
Implements: IReadOnlyList<PublishedMessage>

Represents a collection of messages published through an `InMemoryTestHarness` during test execution.

Members (5)

  • methodContains
    public bool Contains(string messageType)

    Determines whether any published message matches the specified message type.

    messageType: string
    The message type identifier to locate.

    Returns: `true` if a matching message was published; otherwise, `false`.

  • methodGetEnumerator
    public IEnumerator<PublishedMessage> GetEnumerator()

    Inherits documentation from base type or interface.

  • methodOfType
    public IEnumerable<PublishedMessage> OfType(string messageType)

    Filters the published messages by the specified message type.

    messageType: string
    The message type identifier to filter by.

    Returns: An enumerable collection of matching published messages.

  • propertyCount
    public int Count { get; }

    Gets the number of published messages in the collection.

  • propertythis[int index]
    public PublishedMessage this[int index] { get; }

    Gets the published message at the specified index.

    index: int
    The zero-based index of the message to get.

    Returns: The published message at the specified index.

EricksonLopez.Messaging.Transport#

6
interface

IBatchMessageTransport

Assembly: EricksonLopez.Messaging
public interface IBatchMessageTransport : IMessageTransport
Implements: IMessageTransport

Defines a message transport specialization supporting batch publishing of raw serialized messages.

Members (1)

  • methodPublishBatchRawAsync
    ValueTask<Result> PublishBatchRawAsync(string destination, IReadOnlyList<(ReadOnlyMemory<byte> Payload, TransportMessageMetadata Metadata)> batch, CancellationToken cancellationToken = default)

    Publishes a batch of raw serialized envelopes to the specified broker destination in a single operation.

    destination: string
    The target topic, queue, or exchange.
    batch: IReadOnlyList<(ReadOnlyMemory<byte> Payload, TransportMessageMetadata Metadata)>
    The collection of payload and metadata items to publish.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the batch publication outcome.

interface

IDeferableMessageTransport

Assembly: EricksonLopez.Messaging
public interface IDeferableMessageTransport : IMessageTransport
Implements: IMessageTransport

Defines a message transport specialization supporting scheduled message delivery with a configured delay.

Members (1)

  • methodDeferRawAsync
    ValueTask<Result> DeferRawAsync(string destination, ReadOnlyMemory<byte> payload, TransportMessageMetadata metadata, TimeSpan delay, CancellationToken cancellationToken = default)

    Defers the publishing of a raw serialized envelope to the specified broker destination with a configured delay.

    destination: string
    The target topic, queue, or exchange.
    payload: ReadOnlyMemory<byte>
    The raw serialized payload bytes.
    metadata: TransportMessageMetadata
    The associated metadata headers.
    delay: TimeSpan
    The duration to delay delivery before making the message available to consumers.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the transport acknowledgement outcome.

interface

IMessageTransport

Assembly: EricksonLopez.Messaging
public interface IMessageTransport : IAsyncDisposable
Implements: IAsyncDisposable

Defines a physical transport driver for publishing and subscribing to messaging destinations.

Members (2)

  • methodPublishRawAsync
    ValueTask<Result> PublishRawAsync(string destination, ReadOnlyMemory<byte> payload, TransportMessageMetadata metadata, CancellationToken cancellationToken = default)

    Publishes a raw serialized envelope to the specified broker destination.

    destination: string
    The target topic, queue, or exchange.
    payload: ReadOnlyMemory<byte>
    The raw serialized payload bytes.
    metadata: TransportMessageMetadata
    The associated metadata headers.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the transport acknowledgement outcome.

  • methodSubscribeAsync
    ValueTask<Result> SubscribeAsync(string destination, Func<ReadOnlyMemory<byte>, TransportMessageMetadata, CancellationToken, ValueTask<TransportAckResult>> messageHandler, TransportSubscriptionOptions options, CancellationToken cancellationToken = default)

    Starts consuming messages from the specified destination using the provided callback.

    destination: string
    The destination queue or topic name.
    messageHandler: Func<ReadOnlyMemory<byte>, TransportMessageMetadata, CancellationToken, ValueTask<TransportAckResult>>
    The callback invoked for each received message packet.
    options: TransportSubscriptionOptions
    The subscription concurrency and prefetch options.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the subscription outcome.

interface

ITransportReadinessCheck

Assembly: EricksonLopez.Messaging
public interface ITransportReadinessCheck

Defines an optional readiness probe contract for physical message transports.

Members (1)

  • methodCheckReadinessAsync
    ValueTask<HealthCheckResult> CheckReadinessAsync(CancellationToken cancellationToken = default)

    Verifies that the underlying broker connection, socket, or channel is healthy and ready to process traffic.

    cancellationToken: CancellationToken
    A token to cancel the check operation.

    Returns: A `ValueTask<HealthCheckResult>` indicating transport readiness status.

enum

TransportAckResult

Assembly: EricksonLopez.Messaging
public enum TransportAckResult

Specifies acknowledgment outcomes returned to the transport after processing a message.

Members (3)

  • fieldAck
    Ack = 0

    Indicates that message processing succeeded and the message should be acknowledged and removed from the queue.

  • fieldDeadLetter
    DeadLetter = 2

    Indicates that a fatal failure occurred and the message should be routed to a dead-letter queue.

  • fieldNackRequeue
    NackRequeue = 1

    Indicates that a transient failure occurred and the message should be rejected and requeued for retry.

class

TransportSubscriptionOptions

Assembly: EricksonLopez.Messaging
public sealed class TransportSubscriptionOptions

Specifies configuration options for a transport subscription.

Members (3)

  • propertyConsumerGroup
    public string? ConsumerGroup { get; set; }

    Gets or sets the consumer group identifier or queue name used to coordinate competing consumers.

  • propertyMaxConcurrency
    public int MaxConcurrency { get; set; }

    Gets or sets the maximum number of concurrent message executions allowed.

  • propertyPrefetchCount
    public int PrefetchCount { get; set; }

    Gets or sets the number of messages to prefetch from the broker before processing begins.

EricksonLopez.Messaging.Transport.AwsSqs#

2
class

AwsSqsMessageTransport

Assembly: EricksonLopez.Messaging.AwsSqs
public sealed class AwsSqsMessageTransport : IMessageTransport, IAsyncDisposable, IDisposable
Implements: IAsyncDisposable, IDisposable, IMessageTransport

Provides an AWS SQS message transport driver implementing `IMessageTransport`.

Members (5)

  • constructorAwsSqsMessageTransport
    public AwsSqsMessageTransport(IOptions<AwsSqsTransportOptions>? options = null, IAmazonSQS? sqsClient = null, ILogger<AwsSqsMessageTransport>? logger = null)

    Initializes a new instance of the `AwsSqsMessageTransport` class with the specified options, SQS client, and logger.

    options: IOptions<AwsSqsTransportOptions>?
    The AWS SQS transport configuration options, if specified.
    sqsClient: IAmazonSQS?
    The explicit Amazon SQS client instance, if specified.
    logger: ILogger<AwsSqsMessageTransport>?
    The logger instance, if specified.
  • methodDispose
    public void Dispose()

    Releases the resources used by this instance.

  • methodDisposeAsync
    public async ValueTask DisposeAsync()

    Asynchronously releases the resources used by this instance.

    Returns: A value task representing the asynchronous disposal operation.

  • methodPublishRawAsync
    public async ValueTask<AppResult> PublishRawAsync(string destination, ReadOnlyMemory<byte> payload, AppMessageMetadata metadata, CancellationToken cancellationToken = default)

    Publishes a raw serialized envelope to the specified broker destination.

    destination: string
    The target topic, queue, or exchange.
    payload: ReadOnlyMemory<byte>
    The raw serialized payload bytes.
    metadata: AppMessageMetadata
    The associated metadata headers.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the transport acknowledgement outcome.

    Exceptions: ArgumentException: `destination` is `null`, empty, or consists only of white-space characters; ArgumentNullException: `metadata` is `null`; ObjectDisposedException: The transport has been disposed

  • methodSubscribeAsync
    public ValueTask<AppResult> SubscribeAsync(string destination, Func<ReadOnlyMemory<byte>, AppMessageMetadata, CancellationToken, ValueTask<TransportAckResult>> messageHandler, TransportSubscriptionOptions options, CancellationToken cancellationToken = default)

    Starts consuming messages from the specified destination using the provided callback.

    destination: string
    The destination queue or topic name.
    messageHandler: Func<ReadOnlyMemory<byte>, AppMessageMetadata, CancellationToken, ValueTask<TransportAckResult>>
    The callback invoked for each received message packet.
    options: TransportSubscriptionOptions
    The subscription concurrency and prefetch options.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the subscription outcome.

    Exceptions: ArgumentException: `destination` is `null`, empty, or consists only of white-space characters; ArgumentNullException: `messageHandler` or `options` is `null`; ObjectDisposedException: The transport has been disposed

class

AwsSqsTransportOptions

Assembly: EricksonLopez.Messaging.AwsSqs
public sealed class AwsSqsTransportOptions

Specifies configuration options for the AWS SQS message transport.

Members (4)

  • propertyMaxNumberOfMessages
    public int MaxNumberOfMessages { get; set; }

    Gets or sets the maximum number of messages to retrieve in a single batch.

  • propertyRegion
    public string Region { get; set; }

    Gets or sets the AWS region system name (e.g., "us-east-1").

  • propertyServiceUrl
    public string? ServiceUrl { get; set; }

    Gets or sets the optional explicit service endpoint URL for local emulation or custom endpoints.

  • propertyWaitTimeSeconds
    public int WaitTimeSeconds { get; set; }

    Gets or sets the message poll wait time in seconds for long polling.

EricksonLopez.Messaging.Transport.AzureServiceBus#

2
class

AzureServiceBusMessageTransport

Assembly: EricksonLopez.Messaging.AzureServiceBus
public sealed class AzureServiceBusMessageTransport : IDeferableMessageTransport, IBatchMessageTransport, IAsyncDisposable, IDisposable
Implements: IAsyncDisposable, IBatchMessageTransport, IDeferableMessageTransport, IDisposable

Provides an Azure Service Bus message transport driver supporting batching, deferral, and subscription management.

Members (7)

  • constructorAzureServiceBusMessageTransport
    public AzureServiceBusMessageTransport(IOptions<AzureServiceBusTransportOptions>? options = null, ServiceBusClient? client = null, ILogger<AzureServiceBusMessageTransport>? logger = null)

    Initializes a new instance of the `AzureServiceBusMessageTransport` class with the specified options, client, and logger.

    options: IOptions<AzureServiceBusTransportOptions>?
    The Azure Service Bus transport configuration options, if specified.
    client: ServiceBusClient?
    The explicit Azure Service Bus client instance, if specified.
    logger: ILogger<AzureServiceBusMessageTransport>?
    The logger instance, if specified.

    Exceptions: InvalidOperationException: Neither connection string, fully qualified namespace, nor client was configured

  • methodDeferRawAsync
    public async ValueTask<Result> DeferRawAsync(string destination, ReadOnlyMemory<byte> payload, TransportMessageMetadata metadata, TimeSpan delay, CancellationToken cancellationToken = default)

    Defers the publishing of a raw serialized envelope to the specified broker destination with a configured delay.

    destination: string
    The target topic, queue, or exchange.
    payload: ReadOnlyMemory<byte>
    The raw serialized payload bytes.
    metadata: TransportMessageMetadata
    The associated metadata headers.
    delay: TimeSpan
    The duration to delay delivery before making the message available to consumers.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the transport acknowledgement outcome.

    Exceptions: ArgumentException: `destination` is `null`, empty, or consists only of white-space characters; ArgumentNullException: `metadata` is `null`; ObjectDisposedException: The transport has been disposed

  • methodDispose
    public void Dispose()

    Releases the resources used by this instance.

  • methodDisposeAsync
    public async ValueTask DisposeAsync()

    Asynchronously releases the resources used by this instance.

    Returns: A value task representing the asynchronous disposal operation.

  • methodPublishBatchRawAsync
    public async ValueTask<Result> PublishBatchRawAsync(string destination, IReadOnlyList<(ReadOnlyMemory<byte> Payload, TransportMessageMetadata Metadata)> batch, CancellationToken cancellationToken = default)

    Publishes a batch of raw serialized envelopes to the specified broker destination in a single operation.

    destination: string
    The target topic, queue, or exchange.
    batch: IReadOnlyList<(ReadOnlyMemory<byte> Payload, TransportMessageMetadata Metadata)>
    The collection of payload and metadata items to publish.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the batch publication outcome.

    Exceptions: ArgumentException: `destination` is `null`, empty, or consists only of white-space characters; ArgumentNullException: `batch` is `null`; ObjectDisposedException: The transport has been disposed

  • methodPublishRawAsync
    public async ValueTask<Result> PublishRawAsync(string destination, ReadOnlyMemory<byte> payload, TransportMessageMetadata metadata, CancellationToken cancellationToken = default)

    Inherits documentation from base type or interface.

    destination: string
    payload: ReadOnlyMemory<byte>
    metadata: TransportMessageMetadata
    cancellationToken: CancellationToken

    Exceptions: ArgumentException: `destination` is `null`, empty, or consists only of white-space characters; ArgumentNullException: `metadata` is `null`; ObjectDisposedException: The transport has been disposed

  • methodSubscribeAsync
    public async ValueTask<Result> SubscribeAsync(string destination, Func<ReadOnlyMemory<byte>, TransportMessageMetadata, CancellationToken, ValueTask<TransportAckResult>> messageHandler, TransportSubscriptionOptions options, CancellationToken cancellationToken = default)

    Inherits documentation from base type or interface.

    destination: string
    messageHandler: Func<ReadOnlyMemory<byte>, TransportMessageMetadata, CancellationToken, ValueTask<TransportAckResult>>
    options: TransportSubscriptionOptions
    cancellationToken: CancellationToken

    Exceptions: ArgumentException: `destination` is `null`, empty, or consists only of white-space characters; ArgumentNullException: `messageHandler` or `options` is `null`; ObjectDisposedException: The transport has been disposed

class

AzureServiceBusTransportOptions

Assembly: EricksonLopez.Messaging.AzureServiceBus
public sealed class AzureServiceBusTransportOptions

Specifies configuration options for the Azure Service Bus transport.

Members (3)

  • propertyConnectionString
    public string ConnectionString { get; set; }

    Gets or sets the Azure Service Bus connection string for shared access signature authentication.

    Mutually exclusive with `FullyQualifiedNamespace`. When both are set, the connection string takes precedence.

  • propertyCredential
    public global::Azure.Core.TokenCredential? Credential { get; set; }

    Gets or sets the explicit token credential for authentication when using `FullyQualifiedNamespace`.

  • propertyFullyQualifiedNamespace
    public string FullyQualifiedNamespace { get; set; }

    Gets or sets the fully-qualified namespace (e.g., `mynamespace.servicebus.windows.net`) for token credential authentication.

    Use this property together with `Credential` when authenticating via managed identity or a custom credential. Ignored when `ConnectionString` is set.

EricksonLopez.Messaging.Transport.InMemory#

2
class

InMemoryMessageTransport

Assembly: EricksonLopez.Messaging
public sealed class InMemoryMessageTransport : IDeferableMessageTransport, IBatchMessageTransport, IDisposable
Implements: IBatchMessageTransport, IDeferableMessageTransport, IDisposable

Provides an in-memory message transport backed by channels for local development and integration testing. Segregates routing, deferred delivery, and message processing into cohesive SRP components.

Members (7)

  • constructorInMemoryMessageTransport
    public InMemoryMessageTransport(IOptions<InMemoryTransportOptions>? options = null, ILogger<InMemoryMessageTransport>? logger = null, TimeProvider? timeProvider = null)

    Initializes a new instance of the `InMemoryMessageTransport` class with the specified options, logger, and time provider.

    options: IOptions<InMemoryTransportOptions>?
    The transport configuration options.
    logger: ILogger<InMemoryMessageTransport>?
    The logger instance, if specified.
    timeProvider: TimeProvider?
    The time provider for time-based operations, if specified.
  • methodDeferRawAsync
    public async ValueTask<Result> DeferRawAsync(string destination, ReadOnlyMemory<byte> payload, TransportMessageMetadata metadata, TimeSpan delay, CancellationToken cancellationToken = default)

    Defers the publishing of a raw serialized envelope to the specified broker destination with a configured delay.

    destination: string
    The target topic, queue, or exchange.
    payload: ReadOnlyMemory<byte>
    The raw serialized payload bytes.
    metadata: TransportMessageMetadata
    The associated metadata headers.
    delay: TimeSpan
    The duration to delay delivery before making the message available to consumers.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the transport acknowledgement outcome.

    Exceptions: ArgumentException: `destination` is `null`, empty, or consists only of white-space characters; ArgumentNullException: `metadata` is `null`; ObjectDisposedException: The transport has been disposed

  • methodDispose
    public void Dispose()

    Releases the resources used by this instance.

  • methodDisposeAsync
    public ValueTask DisposeAsync()

    Asynchronously releases the resources used by this instance.

    Returns: A value task representing the asynchronous disposal operation.

  • methodPublishBatchRawAsync
    public async ValueTask<Result> PublishBatchRawAsync(string destination, IReadOnlyList<(ReadOnlyMemory<byte> Payload, TransportMessageMetadata Metadata)> batch, CancellationToken cancellationToken = default)

    Publishes a batch of raw serialized envelopes to the specified broker destination in a single operation.

    destination: string
    The target topic, queue, or exchange.
    batch: IReadOnlyList<(ReadOnlyMemory<byte> Payload, TransportMessageMetadata Metadata)>
    The collection of payload and metadata items to publish.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the batch publication outcome.

    Exceptions: ArgumentException: `destination` is `null`, empty, or consists only of white-space characters; ArgumentNullException: `batch` is `null`; ObjectDisposedException: The transport has been disposed

  • methodPublishRawAsync
    public async ValueTask<Result> PublishRawAsync(string destination, ReadOnlyMemory<byte> payload, TransportMessageMetadata metadata, CancellationToken cancellationToken = default)

    Inherits documentation from base type or interface.

    destination: string
    payload: ReadOnlyMemory<byte>
    metadata: TransportMessageMetadata
    cancellationToken: CancellationToken

    Exceptions: ArgumentException: `destination` is `null`, empty, or consists only of white-space characters; ArgumentNullException: `metadata` is `null`; ObjectDisposedException: The transport has been disposed

  • methodSubscribeAsync
    public ValueTask<Result> SubscribeAsync(string destination, Func<ReadOnlyMemory<byte>, TransportMessageMetadata, CancellationToken, ValueTask<TransportAckResult>> messageHandler, TransportSubscriptionOptions options, CancellationToken cancellationToken = default)

    Inherits documentation from base type or interface.

    destination: string
    messageHandler: Func<ReadOnlyMemory<byte>, TransportMessageMetadata, CancellationToken, ValueTask<TransportAckResult>>
    options: TransportSubscriptionOptions
    cancellationToken: CancellationToken

    Exceptions: ArgumentException: `destination` is `null`, empty, or consists only of white-space characters; ArgumentNullException: `messageHandler` is `null`; ObjectDisposedException: The transport has been disposed

class

InMemoryTransportOptions

Assembly: EricksonLopez.Messaging
public sealed class InMemoryTransportOptions

Specifies configuration options for the in-memory message transport.

Members (2)

  • propertyChannelCapacity
    public int ChannelCapacity { get; set; }

    Gets or sets the capacity limit of the bounded in-memory channels.

  • propertyFullMode
    public BoundedChannelFullMode FullMode { get; set; }

    Gets or sets the behavior when an in-memory channel reaches capacity.

EricksonLopez.Messaging.Transport.Kafka#

2
class

KafkaMessageTransport

Assembly: EricksonLopez.Messaging.Kafka
public sealed class KafkaMessageTransport : IMessageTransport, IAsyncDisposable, IDisposable
Implements: IAsyncDisposable, IDisposable, IMessageTransport

Provides an Apache Kafka message transport driver implementing `IMessageTransport`.

Members (5)

  • constructorKafkaMessageTransport
    public KafkaMessageTransport(IOptions<KafkaTransportOptions>? options = null, IProducer<string, byte[]>? producer = null, Func<ConsumerConfig, IConsumer<string, byte[]>>? consumerFactory = null, ILogger<KafkaMessageTransport>? logger = null)

    Initializes a new instance of the `KafkaMessageTransport` class with the specified options, producer, consumer factory, and logger.

    options: IOptions<KafkaTransportOptions>?
    The Kafka transport configuration options, if specified.
    producer: IProducer<string, byte[]>?
    The explicit Kafka producer instance, if specified.
    consumerFactory: Func<ConsumerConfig, IConsumer<string, byte[]>>?
    The factory for creating Kafka consumer instances, if specified.
    logger: ILogger<KafkaMessageTransport>?
    The logger instance, if specified.
  • methodDispose
    public void Dispose()

    Releases the resources used by this instance.

  • methodDisposeAsync
    public async ValueTask DisposeAsync()

    Asynchronously releases the resources used by this instance.

    Returns: A value task representing the asynchronous disposal operation.

  • methodPublishRawAsync
    public async ValueTask<AppResult> PublishRawAsync(string destination, ReadOnlyMemory<byte> payload, AppMessageMetadata metadata, CancellationToken cancellationToken = default)

    Publishes a raw serialized envelope to the specified broker destination.

    destination: string
    The target topic, queue, or exchange.
    payload: ReadOnlyMemory<byte>
    The raw serialized payload bytes.
    metadata: AppMessageMetadata
    The associated metadata headers.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the transport acknowledgement outcome.

    Exceptions: ArgumentException: `destination` is `null`, empty, or consists only of white-space characters; ArgumentNullException: `metadata` is `null`; ObjectDisposedException: The transport has been disposed

  • methodSubscribeAsync
    public ValueTask<AppResult> SubscribeAsync(string destination, Func<ReadOnlyMemory<byte>, AppMessageMetadata, CancellationToken, ValueTask<TransportAckResult>> messageHandler, TransportSubscriptionOptions options, CancellationToken cancellationToken = default)

    Starts consuming messages from the specified destination using the provided callback.

    destination: string
    The destination queue or topic name.
    messageHandler: Func<ReadOnlyMemory<byte>, AppMessageMetadata, CancellationToken, ValueTask<TransportAckResult>>
    The callback invoked for each received message packet.
    options: TransportSubscriptionOptions
    The subscription concurrency and prefetch options.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the subscription outcome.

    Exceptions: ArgumentException: `destination` is `null`, empty, or consists only of white-space characters; ArgumentNullException: `messageHandler` or `options` is `null`; ObjectDisposedException: The transport has been disposed

class

KafkaTransportOptions

Assembly: EricksonLopez.Messaging.Kafka
public sealed class KafkaTransportOptions

Specifies configuration options for the Apache Kafka transport.

Members (4)

  • propertyBootstrapServers
    public string BootstrapServers { get; set; }

    Gets or sets the comma-delimited list of initial broker host and port addresses.

  • propertyClientId
    public string? ClientId { get; set; }

    Gets or sets the client identifier for broker logging and metrics.

  • propertyEnableAutoCommit
    public bool EnableAutoCommit { get; set; }

    Gets or sets a value indicating whether Kafka offset commits are performed automatically after each message is received.

    When `false`, offsets are committed manually only after the handler returns `TransportAckResult.Ack`.

  • propertyGroupId
    public string GroupId { get; set; }

    Gets or sets the consumer group identifier.

EricksonLopez.Messaging.Transport.RabbitMQ#

2
class

RabbitMqMessageTransport

Assembly: EricksonLopez.Messaging.RabbitMQ
public sealed class RabbitMqMessageTransport : IMessageTransport, IAsyncDisposable, IDisposable
Implements: IAsyncDisposable, IDisposable, IMessageTransport

Provides a RabbitMQ message transport driver implementing `IMessageTransport`.

Members (5)

  • constructorRabbitMqMessageTransport
    public RabbitMqMessageTransport(IOptions<RabbitMqTransportOptions>? options = null, IConnectionFactory? connectionFactory = null, ILogger<RabbitMqMessageTransport>? logger = null)

    Initializes a new instance of the `RabbitMqMessageTransport` class with the specified options, connection factory, and logger.

    options: IOptions<RabbitMqTransportOptions>?
    The RabbitMQ transport configuration options, if specified.
    connectionFactory: IConnectionFactory?
    The explicit RabbitMQ connection factory, if specified.
    logger: ILogger<RabbitMqMessageTransport>?
    The logger instance, if specified.
  • methodDispose
    public void Dispose()

    Releases the resources used by this instance.

  • methodDisposeAsync
    public async ValueTask DisposeAsync()

    Asynchronously releases the resources used by this instance.

    Returns: A value task representing the asynchronous disposal operation.

  • methodPublishRawAsync
    public async ValueTask<Result> PublishRawAsync(string destination, ReadOnlyMemory<byte> payload, TransportMessageMetadata metadata, CancellationToken cancellationToken = default)

    Publishes a raw serialized envelope to the specified broker destination.

    destination: string
    The target topic, queue, or exchange.
    payload: ReadOnlyMemory<byte>
    The raw serialized payload bytes.
    metadata: TransportMessageMetadata
    The associated metadata headers.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the transport acknowledgement outcome.

    Exceptions: ArgumentException: `destination` is `null`, empty, or consists only of white-space characters; ArgumentNullException: `metadata` is `null`; ObjectDisposedException: The transport has been disposed

  • methodSubscribeAsync
    public async ValueTask<Result> SubscribeAsync(string destination, Func<ReadOnlyMemory<byte>, TransportMessageMetadata, CancellationToken, ValueTask<TransportAckResult>> messageHandler, TransportSubscriptionOptions options, CancellationToken cancellationToken = default)

    Starts consuming messages from the specified destination using the provided callback.

    destination: string
    The destination queue or topic name.
    messageHandler: Func<ReadOnlyMemory<byte>, TransportMessageMetadata, CancellationToken, ValueTask<TransportAckResult>>
    The callback invoked for each received message packet.
    options: TransportSubscriptionOptions
    The subscription concurrency and prefetch options.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains a `Result` indicating the subscription outcome.

    Exceptions: ArgumentException: `destination` is `null`, empty, or consists only of white-space characters; ArgumentNullException: `messageHandler` or `options` is `null`; ObjectDisposedException: The transport has been disposed

class

RabbitMqTransportOptions

Assembly: EricksonLopez.Messaging.RabbitMQ
public sealed class RabbitMqTransportOptions

Specifies configuration options for the RabbitMQ transport.

Members (6)

  • propertyExchangeName
    public string ExchangeName { get; set; }

    Gets or sets the default AMQP exchange name for outgoing publish operations.

    An empty string routes messages through the AMQP default exchange, delivering directly to a queue whose name matches the routing key.

  • propertyHostName
    public string HostName { get; set; }

    Gets or sets the RabbitMQ server host name.

  • propertyPassword
    public string Password { get; set; }

    Gets or sets the AMQP password for broker authentication.

  • propertyPort
    public int Port { get; set; }

    Gets or sets the RabbitMQ port number.

  • propertyUserName
    public string UserName { get; set; }

    Gets or sets the AMQP username for broker authentication.

  • propertyVirtualHost
    public string VirtualHost { get; set; }

    Gets or sets the RabbitMQ virtual host.

Microsoft.Extensions.DependencyInjection#

6
class

AwsSqsMessagingServiceCollectionExtensions

Assembly: EricksonLopez.Messaging.AwsSqs
public static class AwsSqsMessagingServiceCollectionExtensions

Provides extension methods for configuring AWS SQS messaging transport in an `IServiceCollection`.

Members (1)

  • methodAddAwsSqsMessagingTransport
    public static IServiceCollection AddAwsSqsMessagingTransport(this IServiceCollection services, Action<AwsSqsTransportOptions>? configure = null)

    Registers AWS SQS as the messaging transport in the service container.

    services: this IServiceCollection
    The service collection to configure.
    configure: Action<AwsSqsTransportOptions>?
    The delegate to configure AWS SQS transport options, if specified.

    Returns: The configured `IServiceCollection`.

    Exceptions: ArgumentNullException: `services` is `null`

class

AzureServiceBusMessagingServiceCollectionExtensions

Assembly: EricksonLopez.Messaging.AzureServiceBus
public static class AzureServiceBusMessagingServiceCollectionExtensions

Provides extension methods for configuring Azure Service Bus transport in an `IServiceCollection`.

Members (1)

  • methodAddAzureServiceBusMessagingTransport
    public static IServiceCollection AddAzureServiceBusMessagingTransport(this IServiceCollection services, Action<AzureServiceBusTransportOptions>? configure = null)

    Registers Azure Service Bus as the messaging transport in the service container.

    services: this IServiceCollection
    The service collection to configure.
    configure: Action<AzureServiceBusTransportOptions>?
    The delegate to configure Azure Service Bus transport options, if specified.

    Returns: The configured `IServiceCollection`.

    Exceptions: ArgumentNullException: `services` is `null`

class

KafkaMessagingServiceCollectionExtensions

Assembly: EricksonLopez.Messaging.Kafka
public static class KafkaMessagingServiceCollectionExtensions

Provides extension methods for configuring Apache Kafka messaging transport in an `IServiceCollection`.

Members (1)

  • methodAddKafkaMessagingTransport
    public static IServiceCollection AddKafkaMessagingTransport(this IServiceCollection services, Action<KafkaTransportOptions>? configure = null)

    Registers Apache Kafka as the messaging transport in the service container.

    services: this IServiceCollection
    The service collection to configure.
    configure: Action<KafkaTransportOptions>?
    The delegate to configure Kafka transport options, if specified.

    Returns: The configured `IServiceCollection`.

    Exceptions: ArgumentNullException: `services` is `null`

class

MessagingIdempotencyServiceCollectionExtensions

Assembly: EricksonLopez.Messaging.Idempotency
public static class MessagingIdempotencyServiceCollectionExtensions

Provides extension methods for registering the distributed idempotency deduplication adapter in an `IServiceCollection`.

Members (1)

  • methodAddMessagingIdempotency
    public static IServiceCollection AddMessagingIdempotency(this IServiceCollection services, Action<MessagingIdempotencyOptions>? configure = null)

    Registers `IdempotencyStoreDeduplicationAdapter` as the `IMessageDeduplicationStore` implementation in the service container. Uses `RemoveAll<IMessageDeduplicationStore>()` to ensure registration order resilience whether called before or after `AddMessaging()`.

    services: this IServiceCollection
    The service collection to configure.
    configure: Action<MessagingIdempotencyOptions>?
    The optional delegate to configure `MessagingIdempotencyOptions`.

    Returns: The configured `IServiceCollection`.

    Exceptions: ArgumentNullException: `services` is `null`

class

MessagingServiceCollectionExtensions

Assembly: EricksonLopez.Messaging
public static class MessagingServiceCollectionExtensions

Provides extension methods for registering messaging services, handlers, and upcasters in an `IServiceCollection`.

Members (3)

  • methodAddMessageHandler<TMessage, THandler>
    public static IServiceCollection AddMessageHandler<TMessage, THandler>(this IServiceCollection services) where TMessage : notnull where THandler : class, IMessageHandler<TMessage>

    Registers a strongly-typed message handler and configures its binding in the dispatcher.

    services: this IServiceCollection
    The service collection to configure.

    Returns: The configured `IServiceCollection`.

    Type parameters: TMessage: The type of the message payload to handle.; THandler: The type of the message handler implementation. Exceptions: ArgumentNullException: `services` is `null`

  • methodAddMessageUpcaster<TOldMessage, TNewMessage, TUpcaster>
    public static IServiceCollection AddMessageUpcaster<TOldMessage, TNewMessage, TUpcaster>(this IServiceCollection services) where TOldMessage : class, IMessage where TNewMessage : class, IMessage where TUpcaster : class, IMessageUpcaster<TOldMessage, TNewMessage>

    Registers a message upcaster for migrating legacy schema payloads to newer schema contracts.

    services: this IServiceCollection
    The service collection to configure.

    Returns: The configured `IServiceCollection`.

    Type parameters: TOldMessage: The previous message contract type.; TNewMessage: The upgraded target message contract type.; TUpcaster: The type of the upcaster implementation. Exceptions: ArgumentNullException: `services` is `null`

  • methodAddMessaging
    public static IServiceCollection AddMessaging(this IServiceCollection services, Action<MessagingOptionsBuilder>? configure = null)

    Registers core messaging infrastructure and in-memory transport services in the service container.

    services: this IServiceCollection
    The service collection to configure.
    configure: Action<MessagingOptionsBuilder>?
    The delegate to configure messaging options and middleware, if specified.

    Returns: The configured `IServiceCollection`.

    Exceptions: ArgumentNullException: `services` is `null`

class

RabbitMqMessagingServiceCollectionExtensions

Assembly: EricksonLopez.Messaging.RabbitMQ
public static class RabbitMqMessagingServiceCollectionExtensions

Provides extension methods for configuring RabbitMQ messaging transport in an `IServiceCollection`.

Members (1)

  • methodAddRabbitMqMessagingTransport
    public static IServiceCollection AddRabbitMqMessagingTransport(this IServiceCollection services, Action<RabbitMqTransportOptions>? configure = null)

    Registers RabbitMQ as the messaging transport in the service container.

    services: this IServiceCollection
    The service collection to configure.
    configure: Action<RabbitMqTransportOptions>?
    The delegate to configure RabbitMQ transport options, if specified.

    Returns: The configured `IServiceCollection`.

    Exceptions: ArgumentNullException: `services` is `null`

OpenTelemetry.Metrics#

1
class

MessagingMeterProviderBuilderExtensions

Assembly: EricksonLopez.Messaging.OpenTelemetry
public static class MessagingMeterProviderBuilderExtensions

Provides extension methods for registering messaging instrumentation with OpenTelemetry `MeterProviderBuilder`.

Members (1)

  • methodAddMessagingInstrumentation
    public static MeterProviderBuilder AddMessagingInstrumentation(this MeterProviderBuilder builder)

    Adds the messaging meter to the OpenTelemetry meter provider.

    builder: this MeterProviderBuilder
    The meter provider builder.

    Returns: The configured `MeterProviderBuilder`.

    Exceptions: ArgumentNullException: `builder` is `null`

OpenTelemetry.Trace#

1
class

MessagingTracerProviderBuilderExtensions

Assembly: EricksonLopez.Messaging.OpenTelemetry
public static class MessagingTracerProviderBuilderExtensions

Provides extension methods for registering messaging instrumentation with OpenTelemetry `TracerProviderBuilder`.

Members (1)

  • methodAddMessagingInstrumentation
    public static TracerProviderBuilder AddMessagingInstrumentation(this TracerProviderBuilder builder)

    Adds the messaging activity source to the OpenTelemetry tracer provider.

    builder: this TracerProviderBuilder
    The tracer provider builder.

    Returns: The configured `TracerProviderBuilder`.

    Exceptions: ArgumentNullException: `builder` is `null`

Search EricksonLopez.* Ecosystem

Type a library name, NuGet package ID, .NET type, or architectural concept to search across the portal.