Class AzureEventBus
- Namespace
- Savvyio.Extensions.QueueStorage.EventDriven
- Assembly
- Savvyio.Extensions.QueueStorage.dll
Provides a combined Azure Event Grid/Azure Storage Queue implementation of the IPublishSubscribeChannel<TRequest>.
public class AzureEventBus : AzureQueue<IIntegrationEvent>, IPublishSubscribeChannel<IIntegrationEvent>, IPublisher<IIntegrationEvent>, ISubscriber<IIntegrationEvent>, IHealthCheckProvider<Uri>
- Inheritance
-
AzureEventBus
- Implements
- Derived
- Inherited Members
Examples
AzureEventBus publishes and receives integration events through Azure Queue Storage. Configure it with AzureQueueOptions and an IMarshaller instance, then use it as IPublishSubscribeChannel<IIntegrationEvent>.
using Savvyio.EventDriven;
using Savvyio.Extensions.QueueStorage;
using Savvyio.Extensions.QueueStorage.EventDriven;
using Savvyio.Messaging;
namespace ExampleApp;
public class AzureEventBusConfig
{
public static AzureQueueOptions CreateOptions()
{
return new AzureQueueOptions
{
ConnectionString = "UseDevelopmentStorage=true",
QueueName = "account-integration-events"
};
}
public static IPublishSubscribeChannel<IIntegrationEvent> AsChannel(AzureEventBus bus) => bus;
}
Constructors
AzureEventBus(IMarshaller, AzureQueueOptions, AzureEventBusOptions)
Initializes a new instance of the AzureEventBus class.
public AzureEventBus(IMarshaller marshaller, AzureQueueOptions azureQueueOptions, AzureEventBusOptions azureEventBusOptions)
Parameters
marshallerIMarshallerThe IMarshaller to use for serializing and deserializing IIntegrationEvent implementations to messages.
azureQueueOptionsAzureQueueOptionsThe AzureQueueOptions for configuring AzureQueue<TRequest>.
azureEventBusOptionsAzureEventBusOptionsThe AzureEventBusOptions used to configure this instance.
AzureEventBus(IMarshaller, AzureQueueOptions, AzureEventBusOptions, QueueServiceClient, QueueClient, EventGridPublisherClient)
Initializes a new instance of the AzureEventBus class with testable Azure clients.
protected AzureEventBus(IMarshaller marshaller, AzureQueueOptions azureQueueOptions, AzureEventBusOptions azureEventBusOptions, QueueServiceClient queueServiceClient, QueueClient queueClient, EventGridPublisherClient eventGridClient)
Parameters
marshallerIMarshallerThe IMarshaller to use for serializing and deserializing IIntegrationEvent implementations to messages.
azureQueueOptionsAzureQueueOptionsThe AzureQueueOptions for configuring AzureQueue<TRequest>.
azureEventBusOptionsAzureEventBusOptionsThe AzureEventBusOptions used to configure this instance.
queueServiceClientQueueServiceClientThe queue service client to use.
queueClientQueueClientThe queue client to use.
eventGridClientEventGridPublisherClientThe event grid publisher client to use.
Fields
CloudEventTypeExtensionAttribute
The attribute name for the CloudEvent type extension.
public const string CloudEventTypeExtensionAttribute = "typeext"
Field Value
Methods
GetHealthCheckTarget()
Gets the Uri representing the health check endpoint for the configured Azure Event Grid topic.
public Uri GetHealthCheckTarget()
Returns
PublishAsync(IMessage<IIntegrationEvent>, Action<AsyncOptions>)
Publishes the specified message asynchronous using Publish-Subscribe Channel/Pub-Sub MEP.
public Task PublishAsync(IMessage<IIntegrationEvent> message, Action<AsyncOptions> setup = null)
Parameters
messageIMessage<IIntegrationEvent>The message to publish.
setupAction<AsyncOptions>The AsyncOptions which may be configured.
Returns
Exceptions
- ArgumentNullException
messagecannot be null.
SubscribeAsync(Func<IMessage<IIntegrationEvent>, CancellationToken, Task>, Action<SubscribeAsyncOptions>)
Subscribe to one or more message(s) asynchronous using Publish-Subscribe Channel/Pub-Sub MEP.
public Task SubscribeAsync(Func<IMessage<IIntegrationEvent>, CancellationToken, Task> asyncHandler, Action<SubscribeAsyncOptions> setup = null)
Parameters
asyncHandlerFunc<IMessage<IIntegrationEvent>, CancellationToken, Task>The function delegate that will handle received messages.
setupAction<SubscribeAsyncOptions>The SubscribeAsyncOptions which may be configured.
Returns
Exceptions
- ArgumentNullException
asyncHandlercannot be null.