Azure Service Bus Operators

Azure Service Bus is a fully managed enterprise message broker with message queues and publish-subscribe topics (in a namespace). Service Bus is used to decouple applications and services from each other. Service Bus that perform operations on entities, such as namespaces, queues, and topics.

The Service Bus REST API provides operations for working with the following resources:
  • Azure Resource Manager

  • Service Bus service

Azure Service Bus Queue Operators

Azure Service Bus Operators helps to interact with Azure Bus Queue based operation like Create, Delete, Send and Receive message in Queue.

Create Azure Service Bus Queue

To create Azure service bus queue with specific Parameter you can use AzureServiceBusCreateQueueOperator.

Below is an example of using this operator to execute an Azure Service Bus Create Queue.

tests/system/microsoft/azure/example_azure_service_bus.py[source]

create_service_bus_queue = AzureServiceBusCreateQueueOperator(
    task_id="create_service_bus_queue",
    queue_name=QUEUE_NAME,
)

Send Message to Azure Service Bus Queue

To Send message or list of message or batch Message to the Azure Service Bus Queue. You can use AzureServiceBusSendMessageOperator.

Below is an example of using this operator to execute an Azure Service Bus Send Message to Queue.

tests/system/microsoft/azure/example_azure_service_bus.py[source]

send_message_to_service_bus_queue = AzureServiceBusSendMessageOperator(
    task_id="send_message_to_service_bus_queue",
    message=MESSAGE,
    queue_name=QUEUE_NAME,
    batch=False,
)

Receive Message Azure Service Bus Queue

To Receive Message or list of message or Batch message in a Queue you can use AzureServiceBusReceiveMessageOperator.

Below is an example of using this operator to execute an Azure Service Bus Create Queue.

tests/system/microsoft/azure/example_azure_service_bus.py[source]

receive_message_service_bus_queue = AzureServiceBusReceiveMessageOperator(
    task_id="receive_message_service_bus_queue",
    queue_name=QUEUE_NAME,
    max_message_count=20,
    max_wait_time=5,
)

Delete Azure Service Bus Queue

To Delete the Azure service bus queue you can use AzureServiceBusDeleteQueueOperator.

Below is an example of using this operator to execute an Azure Service Bus Delete Queue.

tests/system/microsoft/azure/example_azure_service_bus.py[source]

delete_service_bus_queue = AzureServiceBusDeleteQueueOperator(
    task_id="delete_service_bus_queue", queue_name=QUEUE_NAME, trigger_rule="all_done"
)

Azure Service Bus Topic Operators

Azure Service Bus Topic based Operators helps to interact with topic in service bus namespace and it helps to Create, Delete operation for topic.

Create Azure Service Bus Topic

To create Azure service bus topic with specific Parameter you can use AzureServiceBusTopicCreateOperator.

Below is an example of using this operator to execute an Azure Service Bus Create Topic.

tests/system/microsoft/azure/example_azure_service_bus.py[source]

create_service_bus_topic = AzureServiceBusTopicCreateOperator(
    task_id="create_service_bus_topic", topic_name=TOPIC_NAME
)

Delete Azure Service Bus Topic

To Delete the Azure service bus topic you can use AzureServiceBusTopicDeleteOperator.

Below is an example of using this operator to execute an Azure Service Bus Delete topic.

tests/system/microsoft/azure/example_azure_service_bus.py[source]

delete_asb_topic = AzureServiceBusTopicDeleteOperator(
    task_id="delete_asb_topic",
    topic_name=TOPIC_NAME,
)

Azure Service Bus Subscription Operators

Azure Service Bus Subscription based Operators helps to interact topic Subscription in service bus namespace and it helps to Create, Delete operation for subscription under topic.

Create Azure Service Bus Subscription

To create Azure service bus topic Subscription with specific Parameter you can use AzureServiceBusSubscriptionCreateOperator.

Below is an example of using this operator to execute an Azure Service Bus Create Subscription.

tests/system/microsoft/azure/example_azure_service_bus.py[source]

create_service_bus_subscription = AzureServiceBusSubscriptionCreateOperator(
    task_id="create_service_bus_subscription",
    topic_name=TOPIC_NAME,
    subscription_name=SUBSCRIPTION_NAME,
)

Update Azure Service Bus Subscription

To Update the Azure service bus topic Subscription which is already created, with specific Parameter you can use AzureServiceBusUpdateSubscriptionOperator.

Below is an example of using this operator to execute an Azure Service Bus Update Subscription.

tests/system/microsoft/azure/example_azure_service_bus.py[source]

update_service_bus_subscription = AzureServiceBusUpdateSubscriptionOperator(
    task_id="update_service_bus_subscription",
    topic_name=TOPIC_NAME,
    subscription_name=SUBSCRIPTION_NAME,
    max_delivery_count=5,
)

Receive Azure Service Bus Subscription Message

To Receive a Batch messages from a Service Bus Subscription under specific Topic, you can use ASBReceiveSubscriptionMessageOperator.

Below is an example of using this operator to execute an Azure Service Bus Receive Subscription Message.

tests/system/microsoft/azure/example_azure_service_bus.py[source]

receive_message_service_bus_subscription = ASBReceiveSubscriptionMessageOperator(
    task_id="receive_message_service_bus_subscription",
    topic_name=TOPIC_NAME,
    subscription_name=SUBSCRIPTION_NAME,
    max_message_count=10,
)

Delete Azure Service Bus Subscription

To Delete the Azure service bus topic Subscription you can use AzureServiceBusSubscriptionDeleteOperator.

Below is an example of using this operator to execute an Azure Service Bus Delete Subscription under topic.

tests/system/microsoft/azure/example_azure_service_bus.py[source]

delete_service_bus_subscription = AzureServiceBusSubscriptionDeleteOperator(
    task_id="delete_service_bus_subscription",
    topic_name=TOPIC_NAME,
    subscription_name=SUBSCRIPTION_NAME,
    trigger_rule="all_done",
)

Reference

For further information, please refer to the Microsoft documentation:

Was this entry helpful?