Table of Contents

Class DelegatingTransportReceiver

Namespace
Excalibur.Dispatch.Transport
Assembly
Excalibur.Dispatch.Transport.Abstractions.dll

Base class for transport receiver decorators that delegate to an inner receiver. Follows the DelegatingChatClient pattern from Microsoft.Extensions.AI — all virtual methods forward to the inner receiver. Subclasses override specific methods to add behavior (telemetry, dead-letter routing, etc.).

public abstract class DelegatingTransportReceiver : ITransportReceiver, IAsyncDisposable
Inheritance
DelegatingTransportReceiver
Implements
Inherited Members
Extension Methods

Constructors

DelegatingTransportReceiver(ITransportReceiver)

Initializes a new instance of the DelegatingTransportReceiver class.

protected DelegatingTransportReceiver(ITransportReceiver innerReceiver)

Parameters

innerReceiver ITransportReceiver

The inner receiver to delegate to.

Properties

InnerReceiver

Gets the inner receiver that this decorator delegates to.

protected ITransportReceiver InnerReceiver { get; }

Property Value

ITransportReceiver

The inner ITransportReceiver.

Source

Gets the source name (queue or subscription) this receiver is configured for.

public virtual string Source { get; }

Property Value

string

The source name.

Methods

AcknowledgeAsync(TransportReceivedMessage, CancellationToken)

Requests acknowledgement of successful processing of a message.

public virtual Task AcknowledgeAsync(TransportReceivedMessage message, CancellationToken cancellationToken)

Parameters

message TransportReceivedMessage

The message to acknowledge.

cancellationToken CancellationToken

Cancellation token for the operation.

Returns

Task

Task representing the acknowledgment operation.

Remarks

Returning normally means the provider completed the supported acknowledgement operation without reporting failure or refusal through its available response. Confirmation guarantees depend on the transport; completion does not guarantee durable broker acceptance or prevent redelivery. An implementation must throw on an observed failure, refusal, or unsupported operation. Callers must remain idempotent.

Exceptions

TransportSettlementException

The acknowledgement could not be completed or its outcome could not be determined. The broker may have accepted it before the failure became observable. Read RedeliveryExpectation to see whether the transport could determine redelivery, and Retryability before retrying the settlement. Clients of this interface must be idempotent.

DisposeAsync()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

public virtual ValueTask DisposeAsync()

Returns

ValueTask

A task that represents the asynchronous dispose operation.

GetService(Type)

Gets the underlying transport service (e.g., IConsumer, ServiceBusReceiver, IAmazonSQS).

public virtual object? GetService(Type serviceType)

Parameters

serviceType Type

The type of service to retrieve.

Returns

object

The service instance, or null if not available.

Remarks

Follows the IChatClient.GetService() pattern from Microsoft.Extensions.AI. Returns null if the requested service type is not available.

The default implementation answers for any service this instance itself implements, so a transport that provides one directly need not override it. A transport overrides it to hand out its native SDK handle, and a decorator overrides it to answer for itself before deferring to the transport it wraps.

Exceptions

ArgumentNullException

Thrown when serviceType is null.

ReceiveAsync(int, CancellationToken)

Receives messages from the source.

public virtual Task<IReadOnlyList<TransportReceivedMessage>> ReceiveAsync(int maxMessages, CancellationToken cancellationToken)

Parameters

maxMessages int

Maximum number of messages to receive.

cancellationToken CancellationToken

Cancellation token for the operation.

Returns

Task<IReadOnlyList<TransportReceivedMessage>>

The received messages.

RejectAsync(TransportReceivedMessage, string?, bool, CancellationToken)

Rejects a message and optionally requeues it for retry.

public virtual Task RejectAsync(TransportReceivedMessage message, string? reason, bool requeue, CancellationToken cancellationToken)

Parameters

message TransportReceivedMessage

The message to reject.

reason string

The reason for rejection.

requeue bool

Whether to requeue the message for retry.

cancellationToken CancellationToken

Cancellation token for the operation.

Returns

Task

Task representing the reject operation.

Remarks

requeue states the outcome the caller requires: true asks the broker to deliver the message again, false asks it not to. Not every broker can suppress redelivery for a single message, and an implementation that cannot deliver the requested disposition must throw rather than silently substitute another operation. Normal return means the supported operation completed without an observed failure or refusal; broker confirmation and subsequent delivery depend on the transport.

Exceptions

TransportSettlementException

The rejection could not be completed or its outcome could not be determined. The broker may have accepted it before the failure became observable. Read RedeliveryExpectation to see whether the message is expected to arrive again, and Retryability before retrying the settlement. A failed requeue: false may leave a poison message queued.