airflow.providers.microsoft.azure.hooks.asb
¶
Module Contents¶
Classes¶
BaseAzureServiceBusHook class to create session and create connection using connection string. |
|
Interact with the ServiceBusAdministrationClient. |
|
Interact with ServiceBusClient. |
Attributes¶
- class airflow.providers.microsoft.azure.hooks.asb.BaseAzureServiceBusHook(azure_service_bus_conn_id=default_conn_name)[source]¶
Bases:
airflow.hooks.base.BaseHook
BaseAzureServiceBusHook class to create session and create connection using connection string.
- Parameters
azure_service_bus_conn_id (str) – Reference to the Azure Service Bus connection.
- class airflow.providers.microsoft.azure.hooks.asb.AdminClientHook(azure_service_bus_conn_id=default_conn_name)[source]¶
Bases:
BaseAzureServiceBusHook
Interact with the ServiceBusAdministrationClient.
This can create, update, list, and delete resources of a Service Bus namespace. This hook uses the same Azure Service Bus client connection inherited from the base class.
- get_conn()[source]¶
Create a ServiceBusAdministrationClient instance.
This uses the connection string in connection details.
- create_queue(queue_name, max_delivery_count=10, dead_lettering_on_message_expiration=True, enable_batched_operations=True)[source]¶
Create Queue by connecting to service Bus Admin client return the QueueProperties.
- Parameters
queue_name (str) – The name of the queue or a QueueProperties with name.
max_delivery_count (int) – The maximum delivery count. A message is automatically dead lettered after this number of deliveries. Default value is 10..
dead_lettering_on_message_expiration (bool) – A value that indicates whether this subscription has dead letter support when a message expires.
enable_batched_operations (bool) – Value that indicates whether server-side batched operations are enabled.
- class airflow.providers.microsoft.azure.hooks.asb.MessageHook(azure_service_bus_conn_id=default_conn_name)[source]¶
Bases:
BaseAzureServiceBusHook
Interact with ServiceBusClient.
This acts as a high level interface for getting ServiceBusSender and ServiceBusReceiver.
- get_conn()[source]¶
Create and returns ServiceBusClient by using the connection string in connection details.
- send_message(queue_name, messages, batch_message_flag=False)[source]¶
Use ServiceBusClient Send to send message(s) to a Service Bus Queue.
By using
batch_message_flag
, it enables and send message as batch message.
- receive_message(queue_name, max_message_count=1, max_wait_time=None, message_callback=None)[source]¶
Receive a batch of messages at once in a specified Queue name.
- Parameters
queue_name (str) – The name of the queue name or a QueueProperties with name.
max_message_count (int | None) – Maximum number of messages in the batch.
max_wait_time (float | None) – Maximum time to wait in seconds for the first message to arrive.
message_callback (MessageCallback | None) – Optional callback to process each message. If not provided, then the message will be logged and completed. If provided, and throws an exception, the message will be abandoned for future redelivery.
- receive_subscription_message(topic_name, subscription_name, max_message_count, max_wait_time, message_callback=None)[source]¶
Receive a batch of subscription message at once.
This approach is optimal if you wish to process multiple messages simultaneously, or perform an ad-hoc receive as a single call.
- Parameters
subscription_name (str) – The subscription name that will own the rule in topic
topic_name (str) – The topic that will own the subscription rule.
max_message_count (int | None) – Maximum number of messages in the batch. Actual number returned will depend on prefetch_count and incoming stream rate. Setting to None will fully depend on the prefetch config. The default value is 1.
max_wait_time (float | None) – Maximum time to wait in seconds for the first message to arrive. If no messages arrive, and no timeout is specified, this call will not return until the connection is closed. If specified, an no messages arrive within the timeout period, an empty list will be returned.