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.

Connect to Azure Service Bus

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();

Interfaces

IQueueReceiver

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:

IQueue

The interface used to send messages is IQueue. When passing a channel you have to use this format:

  • q/queue name for working with queues
  • t/topic name for working with topics
  • t/topic name/subscription name for 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.

IAzureServiceBus

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
⚠️ **GitHub.com Fallback** ⚠️