diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/_common/auto_lock_renewer.py b/sdk/servicebus/azure-servicebus/azure/servicebus/_common/auto_lock_renewer.py index ecf3074c7a14..186e1842e3a4 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/_common/auto_lock_renewer.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/_common/auto_lock_renewer.py @@ -259,7 +259,7 @@ def register( :param renewable: A locked entity that needs to be renewed. :type renewable: Union[~azure.servicebus.ServiceBusReceivedMessage, ~azure.servicebus.ServiceBusSession] :param max_lock_renewal_duration: A time in seconds that the lock should be maintained for. - Default value is 300 (5 minutes). + Default value is None. If specified, this value will override the default value specified at the constructor. :type max_lock_renewal_duration: Optional[float] :param on_lock_renew_failure: A callback may be specified to be called when the lock is lost on the renewable that is being registered. Default value is None (no callback). diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/_common/message.py b/sdk/servicebus/azure-servicebus/azure/servicebus/_common/message.py index c1c7326dae96..d34c0893c64c 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/_common/message.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/_common/message.py @@ -58,6 +58,14 @@ ) from .._servicebus_receiver import ServiceBusReceiver from azure.core.tracing import AbstractSpan + PrimitiveTypes = Union[ + int, + float, + bytes, + bool, + str, + uuid.UUID + ] _LOGGER = logging.getLogger(__name__) @@ -70,7 +78,9 @@ class ServiceBusMessage( :param body: The data to send in a single message. :type body: Optional[Union[str, bytes]] - :keyword Optional[Dict] application_properties: The user defined properties on the message. + :keyword application_properties: The user defined properties on the message. + :paramtype application_properties: Dict[str, Union[int or float or bool or + bytes or str or uuid.UUID or datetime or None]] :keyword Optional[str] session_id: The session identifier of the message for a sessionful entity. :keyword Optional[str] message_id: The id to identify the message. :keyword Optional[datetime.datetime] scheduled_enqueue_time_utc: The utc scheduled enqueue time to the message. @@ -98,7 +108,7 @@ def __init__( self, body: Optional[Union[str, bytes]], *, - application_properties: Optional[Dict[str, Any]] = None, + application_properties: Optional[Dict[str, "PrimitiveTypes"]] = None, session_id: Optional[str] = None, message_id: Optional[str] = None, scheduled_enqueue_time_utc: Optional[datetime.datetime] = None, diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/_servicebus_client.py b/sdk/servicebus/azure-servicebus/azure/servicebus/_servicebus_client.py index e65bfa7483e2..c6264f8fcdd6 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/_servicebus_client.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/_servicebus_client.py @@ -73,8 +73,8 @@ class ServiceBusClient(object): :keyword float retry_backoff_factor: Delta back-off internal in the unit of second between retries. Default value is 0.8. :keyword float retry_backoff_max: Maximum back-off interval in the unit of second. Default value is 120. - :keyword retry_mode: The delay behavior between retry attempts. Supported values are 'fixed' or 'exponential', - where default is 'exponential'. + :keyword retry_mode: The delay behavior between retry attempts. Supported values are "fixed" or "exponential", + where default is "exponential". :paramtype retry_mode: str .. admonition:: Example: @@ -97,7 +97,7 @@ def __init__( *, retry_total: int = 3, retry_backoff_factor: float = 0.8, - retry_backoff_max: int = 120, + retry_backoff_max: float = 120, retry_mode: str = "exponential", **kwargs: Any ) -> None: @@ -290,13 +290,12 @@ def get_queue_receiver( sessionful queue, otherwise it must be None. In order to receive messages from the next available session, set this to ~azure.servicebus.NEXT_AVAILABLE_SESSION. :paramtype session_id: str or ~azure.servicebus.NEXT_AVAILABLE_SESSION - :keyword sub_queue: If specified, the subqueue this receiver will - connect to. + :keyword sub_queue: If specified, the subqueue this receiver will connect to. This includes the DEAD_LETTER and TRANSFER_DEAD_LETTER queues, holds messages that can't be delivered to any receiver or messages that can't be processed. The default is None, meaning connect to the primary queue. Can be assigned values from `ServiceBusSubQueue` enum or equivalent string values "deadletter" and "transferdeadletter". - :paramtype sub_queue: str or ~azure.servicebus.ServiceBusSubQueue + :paramtype sub_queue: str or ~azure.servicebus.ServiceBusSubQueue or None :keyword receive_mode: The receive_mode with which messages will be retrieved from the entity. The two options are PEEK_LOCK and RECEIVE_AND_DELETE. Messages received with PEEK_LOCK must be settled within a given lock period before they will be removed from the queue. Messages received with RECEIVE_AND_DELETE @@ -445,13 +444,12 @@ def get_subscription_receiver( sessionful subscription, otherwise it must be None. In order to receive messages from the next available session, set this to ~azure.servicebus.NEXT_AVAILABLE_SESSION. :paramtype session_id: str or ~azure.servicebus.NEXT_AVAILABLE_SESSION - :keyword sub_queue: If specified, the subqueue this receiver will - connect to. + :keyword sub_queue: If specified, the subqueue this receiver will connect to. This includes the DEAD_LETTER and TRANSFER_DEAD_LETTER queues, holds messages that can't be delivered to any receiver or messages that can't be processed. The default is None, meaning connect to the primary queue. Can be assigned values from `ServiceBusSubQueue` enum or equivalent string values "deadletter" and "transferdeadletter". - :paramtype sub_queue: str or ~azure.servicebus.ServiceBusSubQueue + :paramtype sub_queue: str or ~azure.servicebus.ServiceBusSubQueue or None :keyword receive_mode: The receive_mode with which messages will be retrieved from the entity. The two options are PEEK_LOCK and RECEIVE_AND_DELETE. Messages received with PEEK_LOCK must be settled within a given lock period before they will be removed from the subscription. Messages received with RECEIVE_AND_DELETE diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/_servicebus_session.py b/sdk/servicebus/azure-servicebus/azure/servicebus/_servicebus_session.py index cd84c3348e4d..d917f0602a12 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/_servicebus_session.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/_servicebus_session.py @@ -30,8 +30,7 @@ class BaseSession(object): - def __init__(self, session_id, receiver): - # type: (str, Union[ServiceBusReceiver, ServiceBusReceiverAsync]) -> None + def __init__(self, session_id: str, receiver: Union["ServiceBusReceiver", "ServiceBusReceiverAsync"]) -> None: self._session_id = session_id self._receiver = receiver self._encoding = "UTF-8" diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/aio/_async_auto_lock_renewer.py b/sdk/servicebus/azure-servicebus/azure/servicebus/aio/_async_auto_lock_renewer.py index ab0acf829ef6..03ac6f6a6358 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/aio/_async_auto_lock_renewer.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/aio/_async_auto_lock_renewer.py @@ -175,8 +175,8 @@ def register( :type receiver: ~azure.servicebus.aio.ServiceBusReceiver :param renewable: A locked entity that needs to be renewed. :type renewable: Union[~azure.servicebus.aio.ServiceBusReceivedMessage,~azure.servicebus.aio.ServiceBusSession] - :param max_lock_renewal_duration: A time in seconds that locks registered to this renewer - should be maintained for. Default value is 300 (5 minutes). + :param max_lock_renewal_duration: A time in seconds that the lock should be maintained for. + Default value is None. If specified, this value will override the default value specified at the constructor. :type max_lock_renewal_duration: Optional[float] :param Optional[AsyncLockRenewFailureCallback] on_lock_renew_failure: An async callback may be specified to be called when the lock is lost on the renewable being registered. diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/aio/_servicebus_client_async.py b/sdk/servicebus/azure-servicebus/azure/servicebus/aio/_servicebus_client_async.py index 984c44c35bac..d8a5e8286f5e 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/aio/_servicebus_client_async.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/aio/_servicebus_client_async.py @@ -66,8 +66,8 @@ class ServiceBusClient(object): :keyword float retry_backoff_factor: Delta back-off internal in the unit of second between retries. Default value is 0.8. :keyword float retry_backoff_max: Maximum back-off interval in the unit of second. Default value is 120. - :keyword retry_mode: The delay behavior between retry attempts. Supported values are 'fixed' or 'exponential', - where default is 'exponential'. + :keyword retry_mode: The delay behavior between retry attempts. Supported values are "fixed" or "exponential", + where default is "exponential". :paramtype retry_mode: str .. admonition:: Example: @@ -90,8 +90,8 @@ def __init__( *, retry_total: int = 3, retry_backoff_factor: float = 0.8, - retry_backoff_max: int = 120, - retry_mode: str = 'exponential', + retry_backoff_max: float = 120, + retry_mode: str = "exponential", **kwargs: Any ) -> None: # If the user provided http:// or sb://, let's be polite and strip that. @@ -278,14 +278,13 @@ def get_queue_receiver( :keyword session_id: A specific session from which to receive. This must be specified for a sessionful queue, otherwise it must be None. In order to receive messages from the next available session, set this to ~azure.servicebus.NEXT_AVAILABLE_SESSION. - :paramtype session_id: str or ~azure.servicebus.NEXT_AVAILABLE_SESSION - :keyword sub_queue: If specified, the subqueue this receiver will - connect to. + :paramtype session_id: str or ~azure.servicebus.NEXT_AVAILABLE_SESSION or None + :keyword sub_queue: If specified, the subqueue this receiver will connect to. This includes the DEAD_LETTER and TRANSFER_DEAD_LETTER queues, holds messages that can't be delivered to any receiver or messages that can't be processed. The default is None, meaning connect to the primary queue. Can be assigned values from `ServiceBusSubQueue` enum or equivalent string values "deadletter" and "transferdeadletter". - :paramtype sub_queue: str or ~azure.servicebus.ServiceBusSubQueue + :paramtype sub_queue: str or ~azure.servicebus.ServiceBusSubQueue or None :keyword receive_mode: The mode with which messages will be retrieved from the entity. The two options are PEEK_LOCK and RECEIVE_AND_DELETE. Messages received with PEEK_LOCK must be settled within a given lock period before they will be removed from the queue. Messages received with RECEIVE_AND_DELETE @@ -431,14 +430,13 @@ def get_subscription_receiver( :keyword session_id: A specific session from which to receive. This must be specified for a sessionful subscription, otherwise it must be None. In order to receive messages from the next available session, set this to ~azure.servicebus.NEXT_AVAILABLE_SESSION. - :paramtype session_id: str or ~azure.servicebus.NEXT_AVAILABLE_SESSION - :keyword sub_queue: If specified, the subqueue this receiver will - connect to. + :paramtype session_id: str or ~azure.servicebus.NEXT_AVAILABLE_SESSION or None + :keyword sub_queue: If specified, the subqueue this receiver will connect to. This includes the DEAD_LETTER and TRANSFER_DEAD_LETTER queues, holds messages that can't be delivered to any receiver or messages that can't be processed. The default is None, meaning connect to the primary queue. Can be assigned values from `ServiceBusSubQueue` enum or equivalent string values "deadletter" and "transferdeadletter". - :paramtype sub_queue: str or ~azure.servicebus.ServiceBusSubQueue + :paramtype sub_queue: str or ~azure.servicebus.ServiceBusSubQueue or None :keyword receive_mode: The mode with which messages will be retrieved from the entity. The two options are PEEK_LOCK and RECEIVE_AND_DELETE. Messages received with PEEK_LOCK must be settled within a given lock period before they will be removed from the subscription. Messages received with RECEIVE_AND_DELETE