Table of Contents

Interface IMessageBusAdapter

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

Interface for message bus adapters that provide transport-specific message delivery capabilities.

public interface IMessageBusAdapter
Extension Methods

Remarks

Message bus adapters serve as the bridge between the Excalibur framework and specific transport technologies (RabbitMQ, Azure Service Bus, Apache Kafka, etc.). They handle the low-level details of message serialization, routing, and delivery while providing a consistent abstraction for the messaging pipeline.

Properties

IsConnected

Gets a value indicating whether this adapter is currently connected and ready for operations.

bool IsConnected { get; }

Property Value

bool

True if the adapter is connected; otherwise, false.

Name

Gets the name of this message bus adapter.

string Name { get; }

Property Value

string

A descriptive name identifying the transport type (e.g., "RabbitMQ", "Azure Service Bus").

Methods

PublishAsync(IDispatchMessage, IMessageContext, CancellationToken)

Publishes a message to the specified destination.

Task<IMessageResult> PublishAsync(IDispatchMessage message, IMessageContext context, CancellationToken cancellationToken)

Parameters

message IDispatchMessage

The message to publish.

context IMessageContext

The message context containing routing and metadata information.

cancellationToken CancellationToken

Token to cancel the publishing operation.

Returns

Task<IMessageResult>

A task representing the publishing operation result.

Exceptions

InvalidOperationException

Thrown when the adapter doesn't support publishing.

SubscribeAsync(string, Func<IDispatchMessage, IMessageContext, CancellationToken, Task<IMessageResult>>, MessageBusOptions?, CancellationToken)

Subscribes to messages of the specified type from the given source.

Task SubscribeAsync(string subscriptionName, Func<IDispatchMessage, IMessageContext, CancellationToken, Task<IMessageResult>> messageHandler, MessageBusOptions? options, CancellationToken cancellationToken)

Parameters

subscriptionName string

The name identifying this subscription.

messageHandler Func<IDispatchMessage, IMessageContext, CancellationToken, Task<IMessageResult>>

The handler to invoke for received messages.

options MessageBusOptions

Subscription-specific configuration options.

cancellationToken CancellationToken

Token to cancel the subscription operation.

Returns

Task

A task representing the subscription operation.

Exceptions

InvalidOperationException

Thrown when the adapter doesn't support subscriptions.

UnsubscribeAsync(string, CancellationToken)

Unsubscribes from messages using the specified subscription name.

Task UnsubscribeAsync(string subscriptionName, CancellationToken cancellationToken)

Parameters

subscriptionName string

The subscription name to unsubscribe.

cancellationToken CancellationToken

Token to cancel the unsubscribe operation.

Returns

Task

A task representing the unsubscribe operation.