airflow.providers.microsoft.azure.hooks.asb

Module Contents

Classes

BaseAzureServiceBusHook

BaseAzureServiceBusHook class to create session and create connection using connection string

AdminClientHook

Interacts with ServiceBusAdministrationClient client

MessageHook

Interacts with ServiceBusClient and acts as a high level interface

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.

conn_name_attr = azure_service_bus_conn_id[source]
default_conn_name = azure_service_bus_default[source]
conn_type = azure_service_bus[source]
hook_name = Azure Service Bus[source]
static get_ui_field_behaviour()[source]

Returns custom field behaviour

abstract get_conn(self)[source]

Returns connection for the hook.

class airflow.providers.microsoft.azure.hooks.asb.AdminClientHook(azure_service_bus_conn_id=default_conn_name)[source]

Bases: BaseAzureServiceBusHook

Interacts with ServiceBusAdministrationClient client to 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(self)[source]

Create and returns ServiceBusAdministrationClient by using the connection string in connection details

create_queue(self, 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.

delete_queue(self, queue_name)[source]

Delete the queue by queue_name in service bus namespace

Parameters

queue_name (str) – The name of the queue or a QueueProperties with name.

delete_subscription(self, subscription_name, topic_name)[source]

Delete a topic subscription entities under a ServiceBus Namespace

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.

class airflow.providers.microsoft.azure.hooks.asb.MessageHook(azure_service_bus_conn_id=default_conn_name)[source]

Bases: BaseAzureServiceBusHook

Interacts with ServiceBusClient and acts as a high level interface for getting ServiceBusSender and ServiceBusReceiver.

get_conn(self)[source]

Create and returns ServiceBusClient by using the connection string in connection details

send_message(self, queue_name, messages, batch_message_flag=False)[source]

By using ServiceBusClient Send message(s) to a Service Bus Queue. By using batch_message_flag it enables and send message as batch message

Parameters
  • queue_name (str) – The name of the queue or a QueueProperties with name.

  • messages (Union[str, List[str]]) – Message which needs to be sent to the queue. It can be string or list of string.

  • batch_message_flag (bool) – bool flag, can be set to True if message needs to be sent as batch message.

static send_list_messages(sender, messages)[source]
static send_batch_message(sender, messages)[source]
receive_message(self, queue_name, max_message_count=1, max_wait_time=None)[source]

Receive a batch of messages at once in a specified Queue name

Parameters
  • queue_name – The name of the queue name or a QueueProperties with name.

  • max_message_count (Optional[int]) – Maximum number of messages in the batch.

  • max_wait_time (Optional[float]) – Maximum time to wait in seconds for the first message to arrive.

Was this entry helpful?