Interface IMessageBusAdapter
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
messageIDispatchMessageThe message to publish.
contextIMessageContextThe message context containing routing and metadata information.
cancellationTokenCancellationTokenToken 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
subscriptionNamestringThe name identifying this subscription.
messageHandlerFunc<IDispatchMessage, IMessageContext, CancellationToken, Task<IMessageResult>>The handler to invoke for received messages.
optionsMessageBusOptionsSubscription-specific configuration options.
cancellationTokenCancellationTokenToken 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
subscriptionNamestringThe subscription name to unsubscribe.
cancellationTokenCancellationTokenToken to cancel the unsubscribe operation.
Returns
- Task
A task representing the unsubscribe operation.