Table of Contents

Interface ITransportSubscriber

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

Push-based transport subscription interface.

Unlike ITransportReceiver (pull-based, returns TransportReceivedMessage), this interface pushes messages to a callback handler. Transports with native push semantics (Kafka consumer groups, RabbitMQ BasicConsume, Azure Event Hubs, Google PubSub streaming pull) implement this interface directly.

Follows the same minimal-interface pattern as ITransportSender and ITransportReceiver.

public interface ITransportSubscriber : IAsyncDisposable
Inherited Members
Extension Methods

Properties

Source

Gets the source (topic, queue, subscription) this subscriber reads from.

string Source { get; }

Property Value

string

Methods

GetService(Type)

Gets the underlying transport service (e.g., IConsumer, IChannel, SubscriberClient). Follows the IChatClient.GetService() pattern from Microsoft.Extensions.AI.

object? GetService(Type serviceType)

Parameters

serviceType Type

Returns

object

Remarks

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.

SubscribeAsync(Func<TransportReceivedMessage, CancellationToken, Task<MessageAction>>, CancellationToken)

Subscribes to receive messages via the provided handler callback. The handler is invoked for each received message. The subscription runs until the cancellationToken is cancelled or DisposeAsync() is called.

Task SubscribeAsync(Func<TransportReceivedMessage, CancellationToken, Task<MessageAction>> handler, CancellationToken cancellationToken)

Parameters

handler Func<TransportReceivedMessage, CancellationToken, Task<MessageAction>>

Callback invoked for each received message. Return Acknowledge to acknowledge, Reject to reject, or Requeue to requeue the message.

cancellationToken CancellationToken

Cancellation token to stop the subscription.

Returns

Task

A task that completes when the subscription ends.