Azure Service Bus - robinrodricks/FluentStorage GitHub Wiki
In order to use Microsoft Azure Service Bus you need to reference
FluentStorage.Azure.ServiceBus first. The provider wraps around the new Microsoft Service Bus SDK package (Azure.Messaging.ServiceBus).
This provider supports both topics and queues, for publishing and receiving.
You can use the AzureServiceBus factory class to connect to Azure Service Bus.
IAzureServiceBus bus = AzureServiceBus.FromConnectionString();
IQueueReceiver rec = AzureServiceBus.ForTopicReceiver();
IQueueReceiver rec = AzureServiceBus.ForReceiver();This package introduces the following methods for the IQueueReceiver interface:
- AzureServiceBusTopicReceiver() - Creates Azure Service Bus Receiver for topic and subscriptions
- AzureServiceBusQueueReceiver() - Creates Azure Service Bus Receiver for queues
Where ServiceBusClientOptions and ServiceBusProcessorOptions are optional parameters to fine-tune the options for the ServiceBusClient and ServiceBusProcessor:
The interface used to send messages is IQueue. When passing a channel you have to use this format:
-
q/queue namefor working with queues -
t/topic namefor working with topics -
t/topic name/subscription namefor working with subscriptions (as subscriptions are embedded inside topics)
All the public methods of IQueue that take a channel (or channel collections) in input need to follow this naming convention.
The new interface IAzureServiceBus extends IQueue. So, if you cast your AzureServiceBusMessenger messenger to IAzureServiceBus you have access to these API methods:
- SendToQueue() - Sends a collection of messages to the specified queue asynchronously.
- SendToQueue() - Sends a message to the specified queue asynchronously.
- SendToTopic() - Sends a collection of messages to the specified topic asynchronously.
- SendToTopic() - Sends a single message to the specified topic asynchronously.
- SendToSubscription() - Sends a collection of messages to the specified topic subscription asynchronously.
- SendToSubscription() - Sends a single message to the specified topic subscription asynchronously.
- CreateQueue() - Create a new Queue in Azure ServiceBus
- CreateTopic() - Create a new Topic in Azure ServiceBus
- CreateSubscription() - Create a new Subscription in Azure ServiceBus
- DeleteQueue() - Deletes the specified queue asynchronously.
- **DeleteSubscription- Deletes the specified topic subscription asynchronously.
- DeleteTopic() - Deletes the specified topic asynchronously.
- CountQueue() - Counts the number of messages in the specified queue asynchronously.
- CountSubscription() - Counts the number of messages in the specified topic subscription asynchronously.
- CountTopic() - Counts the number of messages in the specified topic asynchronously