From 6f3ab0eef5aab369874ba0476e17f63f63871689 Mon Sep 17 00:00:00 2001 From: Kieran Brantner-Magee Date: Wed, 14 Oct 2020 01:07:11 -0700 Subject: [PATCH 1/8] Make sub-client initializers internal (add '_' to from_conn_str for receiver/sender) Remove via_partition_key until we add transactions as a whole. Rename properties to application_properties Rename amqp_message to amqp_annotated_message for consistency --- sdk/servicebus/azure-servicebus/CHANGELOG.md | 8 ++ .../azure/servicebus/_common/message.py | 69 +++-------- .../azure/servicebus/_servicebus_receiver.py | 4 +- .../azure/servicebus/_servicebus_sender.py | 7 +- .../_servicebus_session_receiver.py | 4 +- .../aio/_servicebus_receiver_async.py | 2 +- .../aio/_servicebus_sender_async.py | 2 +- .../aio/_servicebus_session_receiver_async.py | 4 +- .../azure-servicebus/migration_guide.md | 5 + .../sample_code_servicebus_async.py | 4 +- .../sync_samples/sample_code_servicebus.py | 8 +- .../tests/async_tests/test_queues_async.py | 20 ++-- .../tests/async_tests/test_sessions_async.py | 8 +- .../async_tests/test_subscriptions_async.py | 4 +- .../azure-servicebus/tests/test_queues.py | 113 +++++++----------- .../azure-servicebus/tests/test_sessions.py | 20 ++-- .../tests/test_subscriptions.py | 4 +- .../azure-servicebus/tests/utilities.py | 2 +- 18 files changed, 123 insertions(+), 165 deletions(-) diff --git a/sdk/servicebus/azure-servicebus/CHANGELOG.md b/sdk/servicebus/azure-servicebus/CHANGELOG.md index 0b908ed0a305..b7bfd1aa905c 100644 --- a/sdk/servicebus/azure-servicebus/CHANGELOG.md +++ b/sdk/servicebus/azure-servicebus/CHANGELOG.md @@ -15,6 +15,14 @@ * Updated uAMQP dependency to 1.2.11. - Fixed bug where amqp message `footer` and `delivery_annotation` were not encoded into the outgoing payload. +**Breaking Changes** + +* `amqp_message` has been renamed to `amqp_annotated_message` for cross-sdk consistency. +* All `name` parameters in `ServiceBusAdministrationClient` are now precisely specified ala `queue_name` or `rule_name` +* `via_partition_key` is no longer exposed, this is pending a full implementation of transactions as it has no external use. If needed, the underlying value can still be accessed in `Message.amqp_annotated_message.annotations`. +* `Message.properties` has been renamed to `Message.application_properties` for consistency with service verbiage. +* Sub-client (`ServiceBusSender` and `ServiceBusReceiver`) `from_connection_string` initializers have been made internal until needed. Clients should be initialized from root `ServiceBusClient`. + ## 7.0.0b7 (2020-10-05) **Breaking Changes** diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/_common/message.py b/sdk/servicebus/azure-servicebus/azure/servicebus/_common/message.py index 8d3de77eecc4..bcdfc79be767 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/_common/message.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/_common/message.py @@ -26,7 +26,6 @@ _X_OPT_SEQUENCE_NUMBER, _X_OPT_ENQUEUE_SEQUENCE_NUMBER, _X_OPT_PARTITION_KEY, - _X_OPT_VIA_PARTITION_KEY, _X_OPT_LOCKED_UNTIL, _X_OPT_LOCK_TOKEN, _X_OPT_SCHEDULED_ENQUEUE_TIME, @@ -45,7 +44,6 @@ PROPERTIES_DEAD_LETTER_REASON, PROPERTIES_DEAD_LETTER_ERROR_DESCRIPTION, ANNOTATION_SYMBOL_PARTITION_KEY, - ANNOTATION_SYMBOL_VIA_PARTITION_KEY, ANNOTATION_SYMBOL_SCHEDULED_ENQUEUE_TIME, ANNOTATION_SYMBOL_KEY_MAP ) @@ -70,23 +68,22 @@ class Message(object): # pylint: disable=too-many-public-methods,too-many-insta :param body: The data to send in a single message. :type body: Union[str, bytes] - :keyword dict properties: The user defined properties on the message. + :keyword dict application_properties: The user defined properties on the message. :keyword str session_id: The session identifier of the message for a sessionful entity. :keyword str message_id: The id to identify the message. :keyword datetime.datetime scheduled_enqueue_time_utc: The utc scheduled enqueue time to the message. :keyword datetime.timedelta time_to_live: The life duration of a message. :keyword str content_type: The content type descriptor. :keyword str correlation_id: The correlation identifier. - :keyword str label: The application specific label. + :keyword str subject: The application specific subject, sometimes referred to as label. :keyword str partition_key: The partition key for sending a message to a partitioned entity. - :keyword str via_partition_key: The partition key for sending a message into an entity via a partitioned - transfer queue. :keyword str to: The `to` address used for auto_forward chaining scenarios. :keyword str reply_to: The address of an entity to send replies to. :keyword str reply_to_session_id: The session identifier augmenting the `reply_to` address. :keyword str encoding: The encoding for string data. Default is UTF-8. - :ivar AMQPMessage amqp_message: Advanced use only. The internal AMQP message payload that is sent or received. + :ivar AMQPMessage amqp_annotated_message: Advanced use only. + The internal AMQP message payload that is sent or received. .. admonition:: Example: @@ -114,7 +111,7 @@ def __init__(self, body, **kwargs): self._amqp_header = self.message.header else: self._build_message(body) - self.properties = kwargs.pop("properties", None) + self.application_properties = kwargs.pop("application_properties", None) self.session_id = kwargs.pop("session_id", None) self.message_id = kwargs.get("message_id", None) self.content_type = kwargs.pop("content_type", None) @@ -122,13 +119,13 @@ def __init__(self, body, **kwargs): self.to = kwargs.pop("to", None) self.reply_to = kwargs.pop("reply_to", None) self.reply_to_session_id = kwargs.pop("reply_to_session_id", None) - self.label = kwargs.pop("label", None) + self.subject = kwargs.pop("subject", None) self.scheduled_enqueue_time_utc = kwargs.pop("scheduled_enqueue_time_utc", None) self.time_to_live = kwargs.pop("time_to_live", None) self.partition_key = kwargs.pop("partition_key", None) - self.via_partition_key = kwargs.pop("via_partition_key", None) - # If message is the full message, amqp_message is the "public facing interface" for what we expose. - self.amqp_message = AMQPMessage(self.message) # type: AMQPMessage + + # If message is the full message, amqp_annotated_message is the "public facing interface" for what we expose. + self.amqp_annotated_message = AMQPMessage(self.message) # type: AMQPMessage def __str__(self): return str(self.message) @@ -191,7 +188,7 @@ def session_id(self, value): self._amqp_properties.group_id = value @property - def properties(self): + def application_properties(self): # type: () -> dict """The user defined properties on the message. @@ -199,8 +196,8 @@ def properties(self): """ return self.message.application_properties - @properties.setter - def properties(self, value): + @application_properties.setter + def application_properties(self, value): # type: (dict) -> None self.message.application_properties = value @@ -231,33 +228,6 @@ def partition_key(self, value): # type: (str) -> None self._set_message_annotations(_X_OPT_PARTITION_KEY, value) - @property - def via_partition_key(self): - # type: () -> Optional[str] - """ The partition key for sending a message into an entity via a partitioned transfer queue. - - If a message is sent via a transfer queue in the scope of a transaction, this value selects the transfer - queue partition: This is functionally equivalent to `partition_key` and ensures that messages are kept - together and in order as they are transferred. - - See Transfers and Send Via in - `https://docs.microsoft.com/azure/service-bus-messaging/service-bus-transactions#transfers-and-send-via`. - - :rtype: str - """ - via_p_key = None - try: - via_p_key = self.message.annotations.get(_X_OPT_VIA_PARTITION_KEY) or \ - self.message.annotations.get(ANNOTATION_SYMBOL_VIA_PARTITION_KEY) - return via_p_key.decode('UTF-8') - except (AttributeError, UnicodeDecodeError): - return via_p_key - - @via_partition_key.setter - def via_partition_key(self, value): - # type: (str) -> None - self._set_message_annotations(_X_OPT_VIA_PARTITION_KEY, value) - @property def time_to_live(self): # type: () -> Optional[datetime.timedelta] @@ -373,9 +343,9 @@ def correlation_id(self, val): self._amqp_properties.correlation_id = val @property - def label(self): + def subject(self): # type: () -> str - """The application specific label. + """The application specific subject, sometimes referred to as a label. This property enables the application to indicate the purpose of the message to the receiver in a standardized fashion, similar to an email subject line. @@ -387,8 +357,8 @@ def label(self): except (AttributeError, UnicodeDecodeError): return self._amqp_properties.subject - @label.setter - def label(self, val): + @subject.setter + def subject(self, val): # type: (str) -> None self._amqp_properties.subject = val @@ -605,17 +575,16 @@ def _to_outgoing_message(self): body=body, content_type=self.content_type, correlation_id=self.correlation_id, - label=self.label, + subject=self.subject, message_id=self.message_id, partition_key=self.partition_key, - properties=self.properties, + application_properties=self.application_properties, reply_to=self.reply_to, reply_to_session_id=self.reply_to_session_id, session_id=self.session_id, scheduled_enqueue_time_utc=self.scheduled_enqueue_time_utc, time_to_live=self.time_to_live, - to=self.to, - via_partition_key=self.via_partition_key + to=self.to ) @property diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/_servicebus_receiver.py b/sdk/servicebus/azure-servicebus/azure/servicebus/_servicebus_receiver.py index 5d7d92cd1478..6766e471037b 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/_servicebus_receiver.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/_servicebus_receiver.py @@ -137,6 +137,8 @@ def __iter__(self): return self._iter_contextual_wrapper() def _iter_contextual_wrapper(self, max_wait_time=None): + """The purpose of this wrapper is to allow both state restoration (for multiple concurrent iteration) + and per-iter argument passing that requires the former.""" # pylint: disable=protected-access original_timeout = None while True: @@ -311,7 +313,7 @@ def get_streaming_message_iter(self, max_wait_time=None): return self._iter_contextual_wrapper(max_wait_time) @classmethod - def from_connection_string( + def _from_connection_string( cls, conn_str, **kwargs diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/_servicebus_sender.py b/sdk/servicebus/azure-servicebus/azure/servicebus/_servicebus_sender.py index a7eb179d009b..52a68d4ec30f 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/_servicebus_sender.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/_servicebus_sender.py @@ -27,8 +27,7 @@ MGMT_REQUEST_MESSAGE, MGMT_REQUEST_MESSAGES, MGMT_REQUEST_MESSAGE_ID, - MGMT_REQUEST_PARTITION_KEY, - MGMT_REQUEST_VIA_PARTITION_KEY + MGMT_REQUEST_PARTITION_KEY ) if TYPE_CHECKING: @@ -76,8 +75,6 @@ def _build_schedule_request(cls, schedule_time_utc, *messages): message_data[MGMT_REQUEST_SESSION_ID] = message.session_id if message.partition_key: message_data[MGMT_REQUEST_PARTITION_KEY] = message.partition_key - if message.via_partition_key: - message_data[MGMT_REQUEST_VIA_PARTITION_KEY] = message.via_partition_key message_data[MGMT_REQUEST_MESSAGE] = bytearray(message.message.encode_message()) request_body[MGMT_REQUEST_MESSAGES].append(message_data) return request_body @@ -271,7 +268,7 @@ def cancel_scheduled_messages(self, sequence_numbers, **kwargs): ) @classmethod - def from_connection_string( + def _from_connection_string( cls, conn_str, **kwargs diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/_servicebus_session_receiver.py b/sdk/servicebus/azure-servicebus/azure/servicebus/_servicebus_session_receiver.py index 1799c5059e19..9e510c586351 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/_servicebus_session_receiver.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/_servicebus_session_receiver.py @@ -106,7 +106,7 @@ def session(self): return self._session # type: ignore @classmethod - def from_connection_string( + def _from_connection_string( cls, conn_str, **kwargs @@ -163,4 +163,4 @@ def from_connection_string( :caption: Create a new instance of the ServiceBusReceiver from connection string. """ - return super(ServiceBusSessionReceiver, cls).from_connection_string(conn_str, **kwargs) # type: ignore + return super(ServiceBusSessionReceiver, cls)._from_connection_string(conn_str, **kwargs) # type: ignore diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/aio/_servicebus_receiver_async.py b/sdk/servicebus/azure-servicebus/azure/servicebus/aio/_servicebus_receiver_async.py index 099a64a82458..c1ba69261a5f 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/aio/_servicebus_receiver_async.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/aio/_servicebus_receiver_async.py @@ -306,7 +306,7 @@ def get_streaming_message_iter(self, max_wait_time: float = None) -> AsyncIterat return self._IterContextualWrapper(self, max_wait_time) @classmethod - def from_connection_string( + def _from_connection_string( cls, conn_str: str, **kwargs: Any diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/aio/_servicebus_sender_async.py b/sdk/servicebus/azure-servicebus/azure/servicebus/aio/_servicebus_sender_async.py index 483de912fcac..bc22f2fdd560 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/aio/_servicebus_sender_async.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/aio/_servicebus_sender_async.py @@ -214,7 +214,7 @@ async def cancel_scheduled_messages(self, sequence_numbers, **kwargs): ) @classmethod - def from_connection_string( + def _from_connection_string( cls, conn_str: str, **kwargs: Any diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/aio/_servicebus_session_receiver_async.py b/sdk/servicebus/azure-servicebus/azure/servicebus/aio/_servicebus_session_receiver_async.py index 8685fcc8664e..99fe66941351 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/aio/_servicebus_session_receiver_async.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/aio/_servicebus_session_receiver_async.py @@ -90,7 +90,7 @@ def __init__( self._session = ServiceBusSession(self._session_id, self, self._config.encoding) @classmethod - def from_connection_string( + def _from_connection_string( cls, conn_str: str, **kwargs: Any @@ -146,7 +146,7 @@ def from_connection_string( :caption: Create a new instance of the ServiceBusReceiver from connection string. """ - return super(ServiceBusSessionReceiver, cls).from_connection_string(conn_str, **kwargs) # type: ignore + return super(ServiceBusSessionReceiver, cls)._from_connection_string(conn_str, **kwargs) # type: ignore @property def session(self): diff --git a/sdk/servicebus/azure-servicebus/migration_guide.md b/sdk/servicebus/azure-servicebus/migration_guide.md index e06bedda14ec..b9ef78fc5628 100644 --- a/sdk/servicebus/azure-servicebus/migration_guide.md +++ b/sdk/servicebus/azure-servicebus/migration_guide.md @@ -84,6 +84,11 @@ semantics with the sender or receiver lifetime. |---|---|---| | `azure.servicebus.AutoLockRenew().shutdown()` | `azure.servicebus.AutoLockRenew().close()` | [Close an auto-lock-renewer](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/servicebus/azure-servicebus/samples/sync_samples/auto_lock_renew.py) | +### Working with Message properties +| In v0.50 | Equivalent in v7 | Sample | +|---|---|---| +| `azure.servicebus.Message.user_properties` | `azure.servicebus.Message.application_properties` | Some message properties have been renamed, e.g. accessing the application specific properties of a message. | + ## Migration samples diff --git a/sdk/servicebus/azure-servicebus/samples/async_samples/sample_code_servicebus_async.py b/sdk/servicebus/azure-servicebus/samples/async_samples/sample_code_servicebus_async.py index a5b6575cf59f..a3f8db8291d5 100644 --- a/sdk/servicebus/azure-servicebus/samples/async_samples/sample_code_servicebus_async.py +++ b/sdk/servicebus/azure-servicebus/samples/async_samples/sample_code_servicebus_async.py @@ -57,7 +57,7 @@ async def example_create_servicebus_sender_async(): from azure.servicebus.aio import ServiceBusSender servicebus_connection_str = os.environ['SERVICE_BUS_CONNECTION_STR'] queue_name = os.environ['SERVICE_BUS_QUEUE_NAME'] - queue_sender = ServiceBusSender.from_connection_string( + queue_sender = ServiceBusSender._from_connection_string( conn_str=servicebus_connection_str, queue_name=queue_name ) @@ -111,7 +111,7 @@ async def example_create_servicebus_receiver_async(): from azure.servicebus.aio import ServiceBusReceiver servicebus_connection_str = os.environ['SERVICE_BUS_CONNECTION_STR'] queue_name = os.environ['SERVICE_BUS_QUEUE_NAME'] - queue_receiver = ServiceBusReceiver.from_connection_string( + queue_receiver = ServiceBusReceiver._from_connection_string( conn_str=servicebus_connection_str, queue_name=queue_name ) diff --git a/sdk/servicebus/azure-servicebus/samples/sync_samples/sample_code_servicebus.py b/sdk/servicebus/azure-servicebus/samples/sync_samples/sample_code_servicebus.py index e5771c667ef8..8069b770d869 100644 --- a/sdk/servicebus/azure-servicebus/samples/sync_samples/sample_code_servicebus.py +++ b/sdk/servicebus/azure-servicebus/samples/sync_samples/sample_code_servicebus.py @@ -53,7 +53,7 @@ def example_create_servicebus_sender_sync(): from azure.servicebus import ServiceBusSender servicebus_connection_str = os.environ['SERVICE_BUS_CONNECTION_STR'] queue_name = os.environ['SERVICE_BUS_QUEUE_NAME'] - queue_sender = ServiceBusSender.from_connection_string( + queue_sender = ServiceBusSender._from_connection_string( conn_str=servicebus_connection_str, queue_name=queue_name ) @@ -91,7 +91,7 @@ def example_create_servicebus_sender_sync(): from azure.servicebus import ServiceBusClient servicebus_connection_str = os.environ['SERVICE_BUS_CONNECTION_STR'] topic_name = os.environ['SERVICE_BUS_TOPIC_NAME'] - servicebus_client = ServiceBusClient.from_connection_string(conn_str=servicebus_connection_str) + servicebus_client = ServiceBusClient._from_connection_string(conn_str=servicebus_connection_str) with servicebus_client: topic_sender = servicebus_client.get_topic_sender(topic_name=topic_name) # [END create_topic_sender_from_sb_client_sync] @@ -107,7 +107,7 @@ def example_create_servicebus_receiver_sync(): from azure.servicebus import ServiceBusReceiver servicebus_connection_str = os.environ['SERVICE_BUS_CONNECTION_STR'] queue_name = os.environ['SERVICE_BUS_QUEUE_NAME'] - queue_receiver = ServiceBusReceiver.from_connection_string( + queue_receiver = ServiceBusReceiver._from_connection_string( conn_str=servicebus_connection_str, queue_name=queue_name ) @@ -244,7 +244,7 @@ def example_send_and_receive_sync(): print("Sequence number: {}".format(message.sequence_number)) print("Enqueued Sequence numger: {}".format(message.enqueued_sequence_number)) print("Partition Key: {}".format(message.partition_key)) - print("Properties: {}".format(message.properties)) + print("Application Properties: {}".format(message.application_properties)) print("Delivery count: {}".format(message.delivery_count)) print("Message ID: {}".format(message.message_id)) print("Locked until: {}".format(message.locked_until_utc)) diff --git a/sdk/servicebus/azure-servicebus/tests/async_tests/test_queues_async.py b/sdk/servicebus/azure-servicebus/tests/async_tests/test_queues_async.py index 5cc213603bea..4fbe4180f963 100644 --- a/sdk/servicebus/azure-servicebus/tests/async_tests/test_queues_async.py +++ b/sdk/servicebus/azure-servicebus/tests/async_tests/test_queues_async.py @@ -415,8 +415,8 @@ async def test_async_queue_by_servicebus_client_iter_messages_with_retrieve_defe print_message(_logger, message) assert message.dead_letter_reason == 'Testing reason' assert message.dead_letter_error_description == 'Testing description' - assert message.properties[b'DeadLetterReason'] == b'Testing reason' - assert message.properties[b'DeadLetterErrorDescription'] == b'Testing description' + assert message.application_properties[b'DeadLetterReason'] == b'Testing reason' + assert message.application_properties[b'DeadLetterErrorDescription'] == b'Testing description' await message.complete() assert count == 10 @@ -532,8 +532,8 @@ async def test_async_queue_by_servicebus_client_receive_batch_with_deadletter(se count += 1 assert message.dead_letter_reason == 'Testing reason' assert message.dead_letter_error_description == 'Testing description' - assert message.properties[b'DeadLetterReason'] == b'Testing reason' - assert message.properties[b'DeadLetterErrorDescription'] == b'Testing description' + assert message.application_properties[b'DeadLetterReason'] == b'Testing reason' + assert message.application_properties[b'DeadLetterErrorDescription'] == b'Testing description' assert count == 10 @pytest.mark.liveTest @@ -574,8 +574,8 @@ async def test_async_queue_by_servicebus_client_receive_batch_with_retrieve_dead print_message(_logger, message) assert message.dead_letter_reason == 'Testing reason' assert message.dead_letter_error_description == 'Testing description' - assert message.properties[b'DeadLetterReason'] == b'Testing reason' - assert message.properties[b'DeadLetterErrorDescription'] == b'Testing description' + assert message.application_properties[b'DeadLetterReason'] == b'Testing reason' + assert message.application_properties[b'DeadLetterErrorDescription'] == b'Testing description' await message.complete() count += 1 assert count == 10 @@ -1249,7 +1249,7 @@ def message_content(): for i in range(20): yield Message( body="Message no. {}".format(i), - label='1st' + subject='1st' ) sender = sb_client.get_queue_sender(servicebus_queue.name) @@ -1275,12 +1275,12 @@ def message_content(): receive_counter += 1 for message in messages: print_message(_logger, message) - if message.label == '1st': + if message.subject == '1st': message_1st_received_cnt += 1 await message.complete() - message.label = '2nd' + message.subject = '2nd' await sender.send_messages(message) # resending received message - elif message.label == '2nd': + elif message.subject == '2nd': message_2nd_received_cnt += 1 await message.complete() diff --git a/sdk/servicebus/azure-servicebus/tests/async_tests/test_sessions_async.py b/sdk/servicebus/azure-servicebus/tests/async_tests/test_sessions_async.py index cd751fceaf8d..dfa8eb887423 100644 --- a/sdk/servicebus/azure-servicebus/tests/async_tests/test_sessions_async.py +++ b/sdk/servicebus/azure-servicebus/tests/async_tests/test_sessions_async.py @@ -265,8 +265,8 @@ async def test_async_session_by_servicebus_client_iter_messages_with_retrieve_de print_message(_logger, message) assert message.dead_letter_reason == 'Testing reason' assert message.dead_letter_error_description == 'Testing description' - assert message.properties[b'DeadLetterReason'] == b'Testing reason' - assert message.properties[b'DeadLetterErrorDescription'] == b'Testing description' + assert message.application_properties[b'DeadLetterReason'] == b'Testing reason' + assert message.application_properties[b'DeadLetterErrorDescription'] == b'Testing description' await message.complete() assert count == 10 @@ -370,8 +370,8 @@ async def test_async_session_by_servicebus_client_fetch_next_with_retrieve_deadl print_message(_logger, message) assert message.dead_letter_reason == 'Testing reason' assert message.dead_letter_error_description == 'Testing description' - assert message.properties[b'DeadLetterReason'] == b'Testing reason' - assert message.properties[b'DeadLetterErrorDescription'] == b'Testing description' + assert message.application_properties[b'DeadLetterReason'] == b'Testing reason' + assert message.application_properties[b'DeadLetterErrorDescription'] == b'Testing description' await message.complete() count += 1 assert count == 10 diff --git a/sdk/servicebus/azure-servicebus/tests/async_tests/test_subscriptions_async.py b/sdk/servicebus/azure-servicebus/tests/async_tests/test_subscriptions_async.py index 9a11c532a726..fe39605b8bb9 100644 --- a/sdk/servicebus/azure-servicebus/tests/async_tests/test_subscriptions_async.py +++ b/sdk/servicebus/azure-servicebus/tests/async_tests/test_subscriptions_async.py @@ -153,6 +153,6 @@ async def test_topic_by_servicebus_client_receive_batch_with_deadletter(self, se count += 1 assert message.dead_letter_reason == 'Testing reason' assert message.dead_letter_error_description == 'Testing description' - assert message.properties[b'DeadLetterReason'] == b'Testing reason' - assert message.properties[b'DeadLetterErrorDescription'] == b'Testing description' + assert message.application_properties[b'DeadLetterReason'] == b'Testing reason' + assert message.application_properties[b'DeadLetterErrorDescription'] == b'Testing description' assert count == 10 diff --git a/sdk/servicebus/azure-servicebus/tests/test_queues.py b/sdk/servicebus/azure-servicebus/tests/test_queues.py index ea03cceb0d00..c284d9e823ea 100644 --- a/sdk/servicebus/azure-servicebus/tests/test_queues.py +++ b/sdk/servicebus/azure-servicebus/tests/test_queues.py @@ -113,13 +113,12 @@ def test_queue_by_queue_client_conn_str_receive_handler_peeklock(self, servicebu with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(10): message = Message("Handler message no. {}".format(i)) - message.properties = {'key': 'value'} - message.label = 'label' + message.application_properties = {'key': 'value'} + message.subject = 'label' message.content_type = 'application/text' message.correlation_id = 'cid' message.message_id = str(i) message.partition_key = 'pk' - message.via_partition_key = 'via_pk' message.to = 'to' message.reply_to = 'reply_to' sender.send_messages(message) @@ -129,14 +128,13 @@ def test_queue_by_queue_client_conn_str_receive_handler_peeklock(self, servicebu for message in receiver: print_message(_logger, message) assert message.delivery_count == 0 - assert message.properties - assert message.properties[b'key'] == b'value' - assert message.label == 'label' + assert message.application_properties + assert message.application_properties[b'key'] == b'value' + assert message.subject == 'label' assert message.content_type == 'application/text' assert message.correlation_id == 'cid' assert message.message_id == str(count) assert message.partition_key == 'pk' - assert message.via_partition_key == 'via_pk' assert message.to == 'to' assert message.reply_to == 'reply_to' assert message.sequence_number @@ -168,11 +166,9 @@ def test_queue_by_queue_client_send_multiple_messages(self, servicebus_namespace for i in range(10): message = Message("Handler message no. {}".format(i)) message.partition_key = 'pkey' - message.via_partition_key = 'vpkey' message.time_to_live = timedelta(seconds=60) message.scheduled_enqueue_time_utc = utc_now() + timedelta(seconds=60) message.partition_key = None - message.via_partition_key = None message.time_to_live = None message.scheduled_enqueue_time_utc = None message.session_id = None @@ -184,12 +180,11 @@ def test_queue_by_queue_client_send_multiple_messages(self, servicebus_namespace for message in receiver: print_message(_logger, message) assert message.delivery_count == 0 - assert not message.properties - assert not message.label + assert not message.application_properties + assert not message.subject assert not message.content_type assert not message.correlation_id assert not message.partition_key - assert not message.via_partition_key assert not message.to assert not message.reply_to assert not message.scheduled_enqueue_time_utc @@ -221,12 +216,11 @@ def test_queue_by_queue_client_conn_str_receive_handler_receiveanddelete(self, s receive_mode=ReceiveMode.ReceiveAndDelete, max_wait_time=8) as receiver: for message in receiver: - assert not message.properties - assert not message.label + assert not message.application_properties + assert not message.subject assert not message.content_type assert not message.correlation_id assert not message.partition_key - assert not message.via_partition_key assert not message.to assert not message.reply_to assert not message.scheduled_enqueue_time_utc @@ -522,8 +516,8 @@ def test_queue_by_servicebus_client_iter_messages_with_retrieve_deferred_receive print_message(_logger, message) assert message.dead_letter_reason == 'Testing reason' assert message.dead_letter_error_description == 'Testing description' - assert message.properties[b'DeadLetterReason'] == b'Testing reason' - assert message.properties[b'DeadLetterErrorDescription'] == b'Testing description' + assert message.application_properties[b'DeadLetterReason'] == b'Testing reason' + assert message.application_properties[b'DeadLetterErrorDescription'] == b'Testing description' message.complete() assert count == 10 @@ -649,8 +643,8 @@ def test_queue_by_servicebus_client_receive_batch_with_deadletter(self, serviceb count += 1 assert message.dead_letter_reason == 'Testing reason' assert message.dead_letter_error_description == 'Testing description' - assert message.properties[b'DeadLetterReason'] == b'Testing reason' - assert message.properties[b'DeadLetterErrorDescription'] == b'Testing description' + assert message.application_properties[b'DeadLetterReason'] == b'Testing reason' + assert message.application_properties[b'DeadLetterErrorDescription'] == b'Testing description' assert count == 10 @pytest.mark.liveTest @@ -696,8 +690,8 @@ def test_queue_by_servicebus_client_receive_batch_with_retrieve_deadletter(self, print_message(_logger, message) assert message.dead_letter_reason == 'Testing reason' assert message.dead_letter_error_description == 'Testing description' - assert message.properties[b'DeadLetterReason'] == b'Testing reason' - assert message.properties[b'DeadLetterErrorDescription'] == b'Testing description' + assert message.application_properties[b'DeadLetterReason'] == b'Testing reason' + assert message.application_properties[b'DeadLetterErrorDescription'] == b'Testing description' message.complete() count += 1 assert count == 10 @@ -763,13 +757,12 @@ def test_queue_by_servicebus_client_browse_messages_with_receiver(self, serviceb for i in range(5): message = Message( body="Test message", - properties={'key': 'value'}, - label='label', + application_properties={'key': 'value'}, + subject='label', content_type='application/text', correlation_id='cid', message_id='mid', partition_key='pk', - via_partition_key='via_pk', to='to', reply_to='reply_to', time_to_live=timedelta(seconds=60) @@ -782,13 +775,12 @@ def test_queue_by_servicebus_client_browse_messages_with_receiver(self, serviceb for message in messages: print_message(_logger, message) assert b''.join(message.body) == b'Test message' - assert message.properties[b'key'] == b'value' - assert message.label == 'label' + assert message.application_properties[b'key'] == b'value' + assert message.subject == 'label' assert message.content_type == 'application/text' assert message.correlation_id == 'cid' assert message.message_id == 'mid' assert message.partition_key == 'pk' - assert message.via_partition_key == 'via_pk' assert message.to == 'to' assert message.reply_to == 'reply_to' assert message.time_to_live == timedelta(seconds=60) @@ -800,13 +792,12 @@ def test_queue_by_servicebus_client_browse_messages_with_receiver(self, serviceb cnt = 0 for message in receiver: assert b''.join(message.body) == b'Test message' - assert message.properties[b'key'] == b'value' - assert message.label == 'label' + assert message.application_properties[b'key'] == b'value' + assert message.subject == 'label' assert message.content_type == 'application/text' assert message.correlation_id == 'cid' assert message.message_id == 'mid' assert message.partition_key == 'pk' - assert message.via_partition_key == 'via_pk' assert message.to == 'to' assert message.reply_to == 'reply_to' assert message.time_to_live == timedelta(seconds=60) @@ -1150,13 +1141,12 @@ def test_queue_message_batch(self, servicebus_namespace_connection_string, servi def message_content(): for i in range(5): message = Message("Message no. {}".format(i)) - message.properties = {'key': 'value'} - message.label = 'label' + message.application_properties = {'key': 'value'} + message.subject = 'label' message.content_type = 'application/text' message.correlation_id = 'cid' message.message_id = str(i) message.partition_key = 'pk' - message.via_partition_key = 'via_pk' message.to = 'to' message.reply_to = 'reply_to' message.time_to_live = timedelta(seconds=60) @@ -1180,14 +1170,13 @@ def message_content(): count = 0 for message in messages: assert message.delivery_count == 0 - assert message.properties - assert message.properties[b'key'] == b'value' - assert message.label == 'label' + assert message.application_properties + assert message.application_properties[b'key'] == b'value' + assert message.subject == 'label' assert message.content_type == 'application/text' assert message.correlation_id == 'cid' assert message.message_id == str(count) assert message.partition_key == 'pk' - assert message.via_partition_key == 'via_pk' assert message.to == 'to' assert message.reply_to == 'reply_to' assert message.sequence_number @@ -1258,12 +1247,11 @@ def test_queue_schedule_multiple_messages(self, servicebus_namespace_connection_ message_b.message_id = message_id_b message_arry = [message_a, message_b] for message in message_arry: - message.properties = {'key': 'value'} - message.label = 'label' + message.application_properties = {'key': 'value'} + message.subject = 'label' message.content_type = 'application/text' message.correlation_id = 'cid' message.partition_key = 'pk' - message.via_partition_key = 'via_pk' message.to = 'to' message.reply_to = 'reply_to' @@ -1287,13 +1275,12 @@ def test_queue_schedule_multiple_messages(self, servicebus_namespace_connection_ assert messages[0].scheduled_enqueue_time_utc == scheduled_enqueue_time assert messages[0].scheduled_enqueue_time_utc <= messages[0].enqueued_time_utc.replace(microsecond=0) assert messages[0].delivery_count == 0 - assert messages[0].properties - assert messages[0].properties[b'key'] == b'value' - assert messages[0].label == 'label' + assert messages[0].application_properties + assert messages[0].application_properties[b'key'] == b'value' + assert messages[0].subject == 'label' assert messages[0].content_type == 'application/text' assert messages[0].correlation_id == 'cid' assert messages[0].partition_key == 'pk' - assert messages[0].via_partition_key == 'via_pk' assert messages[0].to == 'to' assert messages[0].reply_to == 'reply_to' assert messages[0].sequence_number @@ -1509,28 +1496,26 @@ def test_queue_message_properties(self): scheduled_enqueue_time = (utc_now() + timedelta(seconds=20)).replace(microsecond=0) message = Message( body='data', - properties={'key': 'value'}, + application_properties={'key': 'value'}, session_id='sid', - label='label', + subject='label', content_type='application/text', correlation_id='cid', message_id='mid', partition_key='pk', - via_partition_key='via_pk', to='to', reply_to='reply_to', reply_to_session_id='reply_to_sid', scheduled_enqueue_time_utc=scheduled_enqueue_time ) - assert message.properties - assert message.properties['key'] == 'value' - assert message.label == 'label' + assert message.application_properties + assert message.application_properties['key'] == 'value' + assert message.subject == 'label' assert message.content_type == 'application/text' assert message.correlation_id == 'cid' assert message.message_id == 'mid' assert message.partition_key == 'pk' - assert message.via_partition_key == 'via_pk' assert message.to == 'to' assert message.reply_to == 'reply_to' assert message.session_id == 'sid' @@ -1538,11 +1523,9 @@ def test_queue_message_properties(self): assert message.scheduled_enqueue_time_utc == scheduled_enqueue_time message.partition_key = 'updated' - message.via_partition_key = 'updated' new_scheduled_time = (utc_now() + timedelta(hours=5)).replace(microsecond=0) message.scheduled_enqueue_time_utc = new_scheduled_time assert message.partition_key == 'updated' - assert message.via_partition_key == 'updated' assert message.scheduled_enqueue_time_utc == new_scheduled_time message.partition_key = None @@ -1550,7 +1533,6 @@ def test_queue_message_properties(self): message.scheduled_enqueue_time_utc = None assert message.partition_key is None - assert message.via_partition_key is None assert message.scheduled_enqueue_time_utc is None try: @@ -1569,25 +1551,20 @@ def test_queue_message_properties(self): ) received_message = ReceivedMessage(uamqp_received_message, receiver=None) assert received_message.partition_key == 'r_key' - assert received_message.via_partition_key == 'r_via_key' assert received_message.scheduled_enqueue_time_utc == new_scheduled_time new_scheduled_time = utc_now() + timedelta(hours=1, minutes=49, seconds=32) received_message.partition_key = 'new_r_key' - received_message.via_partition_key = 'new_r_via_key' received_message.scheduled_enqueue_time_utc = new_scheduled_time assert received_message.partition_key == 'new_r_key' - assert received_message.via_partition_key == 'new_r_via_key' assert received_message.scheduled_enqueue_time_utc == new_scheduled_time received_message.partition_key = None - received_message.via_partition_key = None received_message.scheduled_enqueue_time_utc = None assert message.partition_key is None - assert message.via_partition_key is None assert message.scheduled_enqueue_time_utc is None @pytest.mark.liveTest @@ -1603,13 +1580,12 @@ def message_content(): for i in range(20): yield Message( body="Test message", - properties={'key': 'value'}, - label='1st', + application_properties={'key': 'value'}, + subject='1st', content_type='application/text', correlation_id='cid', message_id='mid', partition_key='pk', - via_partition_key='via_pk', to='to', reply_to='reply_to', time_to_live=timedelta(seconds=60) @@ -1637,25 +1613,27 @@ def message_content(): for message in messages: print_message(_logger, message) assert b''.join(message.body) == b'Test message' - assert message.properties[b'key'] == b'value' + assert message.application_properties[b'key'] == b'value' assert message.content_type == 'application/text' assert message.correlation_id == 'cid' assert message.message_id == 'mid' assert message.partition_key == 'pk' - assert message.via_partition_key == 'via_pk' assert message.to == 'to' assert message.reply_to == 'reply_to' assert message.time_to_live == timedelta(seconds=60) - if message.label == '1st': + if message.subject == '1st': message_1st_received_cnt += 1 message.complete() - message.label = '2nd' + message.subject = '2nd' sender.send_messages(message) # resending received message - elif message.label == '2nd': + elif message.subject == '2nd': message_2nd_received_cnt += 1 message.complete() + print("COUNTS&&&&&&&&&&&&&&&&&&&&") + print(message_1st_received_cnt) + print(message_2nd_received_cnt) assert message_1st_received_cnt == 20 and message_2nd_received_cnt == 20 # Network/server might be unstable making flow control ineffective in the leading rounds of connection iteration assert receive_counter < 10 # Dynamic link credit issuing come info effect @@ -1791,6 +1769,7 @@ def test_queue_receiver_respects_max_wait_time_overrides(self, servicebus_namesp with sb_client.get_queue_receiver(servicebus_queue.name, max_wait_time=5) as receiver: time_1 = receiver._handler._counter.get_current_ms() + time_3 = time_1 # In case inner loop isn't hit, fail sanely. for message in receiver.get_streaming_message_iter(max_wait_time=10): messages.append(message) message.complete() diff --git a/sdk/servicebus/azure-servicebus/tests/test_sessions.py b/sdk/servicebus/azure-servicebus/tests/test_sessions.py index a8ff86695eba..5de1346cb918 100644 --- a/sdk/servicebus/azure-servicebus/tests/test_sessions.py +++ b/sdk/servicebus/azure-servicebus/tests/test_sessions.py @@ -59,12 +59,11 @@ def test_session_by_session_client_conn_str_receive_handler_peeklock(self, servi for i in range(3): message = Message("Handler message no. {}".format(i)) message.session_id = session_id - message.properties = {'key': 'value'} - message.label = 'label' + message.application_properties = {'key': 'value'} + message.subject = 'label' message.content_type = 'application/text' message.correlation_id = 'cid' message.message_id = str(i) - message.via_partition_key = 'via_pk' message.to = 'to' message.reply_to = 'reply_to' message.reply_to_session_id = 'reply_to_session_id' @@ -78,13 +77,12 @@ def test_session_by_session_client_conn_str_receive_handler_peeklock(self, servi for message in session: print_message(_logger, message) assert message.delivery_count == 0 - assert message.properties - assert message.properties[b'key'] == b'value' - assert message.label == 'label' + assert message.application_properties + assert message.application_properties[b'key'] == b'value' + assert message.subject == 'label' assert message.content_type == 'application/text' assert message.correlation_id == 'cid' assert message.partition_key == session_id - assert message.via_partition_key == 'via_pk' assert message.to == 'to' assert message.reply_to == 'reply_to' assert message.sequence_number @@ -340,8 +338,8 @@ def test_session_by_servicebus_client_iter_messages_with_retrieve_deferred_recei print_message(_logger, message) assert message.dead_letter_reason == 'Testing reason' assert message.dead_letter_error_description == 'Testing description' - assert message.properties[b'DeadLetterReason'] == b'Testing reason' - assert message.properties[b'DeadLetterErrorDescription'] == b'Testing description' + assert message.application_properties[b'DeadLetterReason'] == b'Testing reason' + assert message.application_properties[b'DeadLetterErrorDescription'] == b'Testing description' message.complete() assert count == 10 @@ -455,8 +453,8 @@ def test_session_by_servicebus_client_receive_with_retrieve_deadletter(self, ser message.complete() assert message.dead_letter_reason == 'Testing reason' assert message.dead_letter_error_description == 'Testing description' - assert message.properties[b'DeadLetterReason'] == b'Testing reason' - assert message.properties[b'DeadLetterErrorDescription'] == b'Testing description' + assert message.application_properties[b'DeadLetterReason'] == b'Testing reason' + assert message.application_properties[b'DeadLetterErrorDescription'] == b'Testing description' count += 1 assert count == 10 diff --git a/sdk/servicebus/azure-servicebus/tests/test_subscriptions.py b/sdk/servicebus/azure-servicebus/tests/test_subscriptions.py index 70f3c91fce57..16152d381cd8 100644 --- a/sdk/servicebus/azure-servicebus/tests/test_subscriptions.py +++ b/sdk/servicebus/azure-servicebus/tests/test_subscriptions.py @@ -173,6 +173,6 @@ def test_subscription_by_servicebus_client_receive_batch_with_deadletter(self, s count += 1 assert message.dead_letter_reason == 'Testing reason' assert message.dead_letter_error_description == 'Testing description' - assert message.properties[b'DeadLetterReason'] == b'Testing reason' - assert message.properties[b'DeadLetterErrorDescription'] == b'Testing description' + assert message.application_properties[b'DeadLetterReason'] == b'Testing reason' + assert message.application_properties[b'DeadLetterErrorDescription'] == b'Testing description' assert count == 10 diff --git a/sdk/servicebus/azure-servicebus/tests/utilities.py b/sdk/servicebus/azure-servicebus/tests/utilities.py index 2d46b00daa29..4649659ae156 100644 --- a/sdk/servicebus/azure-servicebus/tests/utilities.py +++ b/sdk/servicebus/azure-servicebus/tests/utilities.py @@ -30,7 +30,7 @@ def print_message(_logger, message): _logger.debug("Sequence number: {}".format(message.sequence_number)) _logger.debug("Enqueue Sequence numger: {}".format(message.enqueued_sequence_number)) _logger.debug("Partition Key: {}".format(message.partition_key)) - _logger.debug("Properties: {}".format(message.properties)) + _logger.debug("Application Properties: {}".format(message.application_properties)) _logger.debug("Delivery count: {}".format(message.delivery_count)) try: _logger.debug("Locked until: {}".format(message.locked_until_utc)) From d58d63023d164c4ba84c64f40007cfd555087ecc Mon Sep 17 00:00:00 2001 From: Kieran Brantner-Magee Date: Wed, 14 Oct 2020 15:13:36 -0700 Subject: [PATCH 2/8] Fix remaining unit tests (an amqp_annotated_message and internal conn str rename were missed) --- .../azure-servicebus/tests/test_queues.py | 40 +++++++++---------- .../azure-servicebus/tests/test_sb_client.py | 2 +- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/sdk/servicebus/azure-servicebus/tests/test_queues.py b/sdk/servicebus/azure-servicebus/tests/test_queues.py index c284d9e823ea..6116deb3dff9 100644 --- a/sdk/servicebus/azure-servicebus/tests/test_queues.py +++ b/sdk/servicebus/azure-servicebus/tests/test_queues.py @@ -1857,20 +1857,20 @@ def test_message_inner_amqp_properties(self, servicebus_namespace_connection_str message = Message("body") with pytest.raises(AttributeError): # Note: If this is made read-writeable, this would be TypeError - message.amqp_message.properties = {"properties":1} + message.amqp_annotated_message.properties = {"properties":1} # NOTE: These are disabled pending cross-language-sdk consensus on sendability/writeability. - # message.amqp_message.properties.subject = "subject" + # message.amqp_annotated_message.properties.subject = "subject" # - # message.amqp_message.application_properties = {b"application_properties":1} + # message.amqp_annotated_message.application_properties = {b"application_properties":1} # - # message.amqp_message.annotations = {b"annotations":2} - # message.amqp_message.delivery_annotations = {b"delivery_annotations":3} + # message.amqp_annotated_message.annotations = {b"annotations":2} + # message.amqp_annotated_message.delivery_annotations = {b"delivery_annotations":3} # # with pytest.raises(TypeError): - # message.amqp_message.header = {"header":4} - # message.amqp_message.header.priority = 5 + # message.amqp_annotated_message.header = {"header":4} + # message.amqp_annotated_message.header.priority = 5 # - # message.amqp_message.footer = {b"footer":6} + # message.amqp_annotated_message.footer = {b"footer":6} with ServiceBusClient.from_connection_string( servicebus_namespace_connection_string, logging_enable=False) as sb_client: @@ -1879,21 +1879,21 @@ def test_message_inner_amqp_properties(self, servicebus_namespace_connection_str sender.send_messages(message) with sb_client.get_queue_receiver(servicebus_queue.name, max_wait_time=5) as receiver: message = receiver.receive_messages()[0] - assert message.amqp_message.application_properties == None \ - and message.amqp_message.annotations != None \ - and message.amqp_message.delivery_annotations != None \ - and message.amqp_message.footer == None \ - and message.amqp_message.properties != None \ - and message.amqp_message.header != None + assert message.amqp_annotated_message.application_properties == None \ + and message.amqp_annotated_message.annotations != None \ + and message.amqp_annotated_message.delivery_annotations != None \ + and message.amqp_annotated_message.footer == None \ + and message.amqp_annotated_message.properties != None \ + and message.amqp_annotated_message.header != None # NOTE: These are disabled pending cross-language-sdk consensus on sendability/writeability. # - # assert message.amqp_message.properties.subject == b"subject" - # assert message.amqp_message.application_properties[b"application_properties"] == 1 - # assert message.amqp_message.annotations[b"annotations"] == 2 + # assert message.amqp_annotated_message.properties.subject == b"subject" + # assert message.amqp_annotated_message.application_properties[b"application_properties"] == 1 + # assert message.amqp_annotated_message.annotations[b"annotations"] == 2 # # delivery_annotations and footer disabled pending uamqp bug https://github.com/Azure/azure-uamqp-python/issues/169 - # #assert message.amqp_message.delivery_annotations[b"delivery_annotations"] == 3 - # assert message.amqp_message.header.priority == 5 - # #assert message.amqp_message.footer[b"footer"] == 6 + # #assert message.amqp_annotated_message.delivery_annotations[b"delivery_annotations"] == 3 + # assert message.amqp_annotated_message.header.priority == 5 + # #assert message.amqp_annotated_message.footer[b"footer"] == 6 @pytest.mark.liveTest @pytest.mark.live_test_only diff --git a/sdk/servicebus/azure-servicebus/tests/test_sb_client.py b/sdk/servicebus/azure-servicebus/tests/test_sb_client.py index 539c5c45840c..c9bb861cfd32 100644 --- a/sdk/servicebus/azure-servicebus/tests/test_sb_client.py +++ b/sdk/servicebus/azure-servicebus/tests/test_sb_client.py @@ -136,7 +136,7 @@ def test_sb_client_incorrect_queue_conn_str(self, servicebus_queue_authorization # Now do the same but with direct connstr initialization. with pytest.raises(ServiceBusAuthenticationError): - with ServiceBusSender.from_connection_string( + with ServiceBusSender._from_connection_string( servicebus_queue_authorization_rule_connection_string, queue_name=wrong_queue.name, ) as sender: From e90680ce1829f2872ff895848d52ec3fa4564823 Mon Sep 17 00:00:00 2001 From: Kieran Brantner-Magee Date: Wed, 14 Oct 2020 15:21:12 -0700 Subject: [PATCH 3/8] fix test_sb_client from_connection_string naming --- sdk/servicebus/azure-servicebus/tests/test_sb_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/servicebus/azure-servicebus/tests/test_sb_client.py b/sdk/servicebus/azure-servicebus/tests/test_sb_client.py index c9bb861cfd32..85643afd42a8 100644 --- a/sdk/servicebus/azure-servicebus/tests/test_sb_client.py +++ b/sdk/servicebus/azure-servicebus/tests/test_sb_client.py @@ -142,7 +142,7 @@ def test_sb_client_incorrect_queue_conn_str(self, servicebus_queue_authorization ) as sender: sender.send_messages(Message("test")) - with ServiceBusSender.from_connection_string( + with ServiceBusSender._from_connection_string( servicebus_queue_authorization_rule_connection_string, queue_name=servicebus_queue.name, ) as sender: From 4af70138b337575e98cbbffc76fad902884f0d32 Mon Sep 17 00:00:00 2001 From: Kieran Brantner-Magee Date: Mon, 26 Oct 2020 15:39:41 -0700 Subject: [PATCH 4/8] PR fixes; remove debug prints from a test, and add a line to changelog for label vs subject --- sdk/servicebus/azure-servicebus/CHANGELOG.md | 1 + sdk/servicebus/azure-servicebus/tests/test_queues.py | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/sdk/servicebus/azure-servicebus/CHANGELOG.md b/sdk/servicebus/azure-servicebus/CHANGELOG.md index b7bfd1aa905c..b6f2abcdcfaa 100644 --- a/sdk/servicebus/azure-servicebus/CHANGELOG.md +++ b/sdk/servicebus/azure-servicebus/CHANGELOG.md @@ -22,6 +22,7 @@ * `via_partition_key` is no longer exposed, this is pending a full implementation of transactions as it has no external use. If needed, the underlying value can still be accessed in `Message.amqp_annotated_message.annotations`. * `Message.properties` has been renamed to `Message.application_properties` for consistency with service verbiage. * Sub-client (`ServiceBusSender` and `ServiceBusReceiver`) `from_connection_string` initializers have been made internal until needed. Clients should be initialized from root `ServiceBusClient`. +* `Message.label` has been renamed to `Message.subject`. ## 7.0.0b7 (2020-10-05) diff --git a/sdk/servicebus/azure-servicebus/tests/test_queues.py b/sdk/servicebus/azure-servicebus/tests/test_queues.py index 6116deb3dff9..8faa8792be0c 100644 --- a/sdk/servicebus/azure-servicebus/tests/test_queues.py +++ b/sdk/servicebus/azure-servicebus/tests/test_queues.py @@ -1631,9 +1631,6 @@ def message_content(): message_2nd_received_cnt += 1 message.complete() - print("COUNTS&&&&&&&&&&&&&&&&&&&&") - print(message_1st_received_cnt) - print(message_2nd_received_cnt) assert message_1st_received_cnt == 20 and message_2nd_received_cnt == 20 # Network/server might be unstable making flow control ineffective in the leading rounds of connection iteration assert receive_counter < 10 # Dynamic link credit issuing come info effect From e7cbeecedd4b1276d3d5f1f5d2d7df96d0e9c522 Mon Sep 17 00:00:00 2001 From: Kieran Brantner-Magee Date: Thu, 29 Oct 2020 11:59:15 -0700 Subject: [PATCH 5/8] lint fix, unneeded import --- sdk/servicebus/azure-servicebus/azure/servicebus/exceptions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/exceptions.py b/sdk/servicebus/azure-servicebus/azure/servicebus/exceptions.py index d1bb0ab66e80..ba07eb19ec11 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/exceptions.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/exceptions.py @@ -4,7 +4,7 @@ # license information. # ------------------------------------------------------------------------- -from typing import Optional, Any +from typing import Optional from uamqp import errors, constants from azure.core.exceptions import AzureError From 918ea07b4721e8a066ea7d9d49b03d9257f625c4 Mon Sep 17 00:00:00 2001 From: "Adam Ling (MSFT)" Date: Fri, 30 Oct 2020 15:36:39 -0700 Subject: [PATCH 6/8] Update sdk/servicebus/azure-servicebus/samples/sync_samples/sample_code_servicebus.py --- .../samples/sync_samples/sample_code_servicebus.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/servicebus/azure-servicebus/samples/sync_samples/sample_code_servicebus.py b/sdk/servicebus/azure-servicebus/samples/sync_samples/sample_code_servicebus.py index f3e5097ca739..986d0dde600a 100644 --- a/sdk/servicebus/azure-servicebus/samples/sync_samples/sample_code_servicebus.py +++ b/sdk/servicebus/azure-servicebus/samples/sync_samples/sample_code_servicebus.py @@ -91,7 +91,7 @@ def example_create_servicebus_sender_sync(): from azure.servicebus import ServiceBusClient servicebus_connection_str = os.environ['SERVICE_BUS_CONNECTION_STR'] topic_name = os.environ['SERVICE_BUS_TOPIC_NAME'] - servicebus_client = ServiceBusClient._from_connection_string(conn_str=servicebus_connection_str) + servicebus_client = ServiceBusClient.from_connection_string(conn_str=servicebus_connection_str) with servicebus_client: topic_sender = servicebus_client.get_topic_sender(topic_name=topic_name) # [END create_topic_sender_from_sb_client_sync] From 9aa037b338e2f7b02833ffa5ff9691b1db415941 Mon Sep 17 00:00:00 2001 From: KieranBrantnerMagee Date: Tue, 3 Nov 2020 13:22:05 -0800 Subject: [PATCH 7/8] Apply suggestions from code review Rename Message->ServiceBusMessage in documentation to align with concurrent changes in master. Co-authored-by: Adam Ling (MSFT) --- sdk/servicebus/azure-servicebus/CHANGELOG.md | 8 ++++---- sdk/servicebus/azure-servicebus/migration_guide.md | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sdk/servicebus/azure-servicebus/CHANGELOG.md b/sdk/servicebus/azure-servicebus/CHANGELOG.md index 127bbb791c6f..b228ce53c6f6 100644 --- a/sdk/servicebus/azure-servicebus/CHANGELOG.md +++ b/sdk/servicebus/azure-servicebus/CHANGELOG.md @@ -55,12 +55,12 @@ now raise more concrete exception other than `MessageSettleFailed` and `ServiceB **Breaking Changes** -* `amqp_message` has been renamed to `amqp_annotated_message` for cross-sdk consistency. +* `ServiceBusMessage.amqp_message` has been renamed to `ServiceBusMessage.amqp_annotated_message` for cross-sdk consistency. * All `name` parameters in `ServiceBusAdministrationClient` are now precisely specified ala `queue_name` or `rule_name` -* `via_partition_key` is no longer exposed, this is pending a full implementation of transactions as it has no external use. If needed, the underlying value can still be accessed in `Message.amqp_annotated_message.annotations`. -* `Message.properties` has been renamed to `Message.application_properties` for consistency with service verbiage. +* `ServiceBusMessage.via_partition_key` is no longer exposed, this is pending a full implementation of transactions as it has no external use. If needed, the underlying value can still be accessed in `ServiceBusMessage.amqp_annotated_message.annotations`. +* `ServiceBusMessage.properties` has been renamed to `ServiceBusMessage.application_properties` for consistency with service verbiage. * Sub-client (`ServiceBusSender` and `ServiceBusReceiver`) `from_connection_string` initializers have been made internal until needed. Clients should be initialized from root `ServiceBusClient`. -* `Message.label` has been renamed to `Message.subject`. +* `ServiceBusMessage.label` has been renamed to `ServiceBusMessage.subject`. ## 7.0.0b7 (2020-10-05) diff --git a/sdk/servicebus/azure-servicebus/migration_guide.md b/sdk/servicebus/azure-servicebus/migration_guide.md index ed8c5540d914..338d493310ae 100644 --- a/sdk/servicebus/azure-servicebus/migration_guide.md +++ b/sdk/servicebus/azure-servicebus/migration_guide.md @@ -87,7 +87,7 @@ semantics with the sender or receiver lifetime. ### Working with Message properties | In v0.50 | Equivalent in v7 | Sample | |---|---|---| -| `azure.servicebus.Message.user_properties` | `azure.servicebus.Message.application_properties` | Some message properties have been renamed, e.g. accessing the application specific properties of a message. | +| `azure.servicebus.Message.user_properties` | `azure.servicebus.ServiceBusMessage.application_properties` | Some message properties have been renamed, e.g. accessing the application specific properties of a message. | ## Migration samples From 61efe549e74c3483e8c24867cc787c4959e1cac2 Mon Sep 17 00:00:00 2001 From: Kieran Brantner-Magee Date: Tue, 3 Nov 2020 13:30:07 -0800 Subject: [PATCH 8/8] Unify Breaking Changes sections in changelog for b8 Rename AMQPMessage to AMQPAnnotatedMessage to match property name and other SDKs. --- sdk/servicebus/azure-servicebus/CHANGELOG.md | 16 +++++++--------- .../azure/servicebus/_common/message.py | 6 +++--- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/sdk/servicebus/azure-servicebus/CHANGELOG.md b/sdk/servicebus/azure-servicebus/CHANGELOG.md index b228ce53c6f6..d029bb3cc44a 100644 --- a/sdk/servicebus/azure-servicebus/CHANGELOG.md +++ b/sdk/servicebus/azure-servicebus/CHANGELOG.md @@ -46,21 +46,19 @@ now raise more concrete exception other than `MessageSettleFailed` and `ServiceB - Changed `ServiceBusReceivedMessage.renew_lock` to `ServiceBusReceiver.renew_message_lock` * `AutoLockRenewer.register` now takes `ServiceBusReceiver` as a positional parameter. * Removed `encoding` support from `ServiceBusMessage`. - -**BugFixes** - -* Updated uAMQP dependency to 1.2.12. - - Added support for Python 3.9. - - Fixed bug where amqp message `footer` and `delivery_annotation` were not encoded into the outgoing payload. - -**Breaking Changes** - * `ServiceBusMessage.amqp_message` has been renamed to `ServiceBusMessage.amqp_annotated_message` for cross-sdk consistency. * All `name` parameters in `ServiceBusAdministrationClient` are now precisely specified ala `queue_name` or `rule_name` * `ServiceBusMessage.via_partition_key` is no longer exposed, this is pending a full implementation of transactions as it has no external use. If needed, the underlying value can still be accessed in `ServiceBusMessage.amqp_annotated_message.annotations`. * `ServiceBusMessage.properties` has been renamed to `ServiceBusMessage.application_properties` for consistency with service verbiage. * Sub-client (`ServiceBusSender` and `ServiceBusReceiver`) `from_connection_string` initializers have been made internal until needed. Clients should be initialized from root `ServiceBusClient`. * `ServiceBusMessage.label` has been renamed to `ServiceBusMessage.subject`. +* `ServiceBusMessage.amqp_annotated_message` has had its type renamed from `AMQPMessage` to `AMQPAnnotatedMessage` + +**BugFixes** + +* Updated uAMQP dependency to 1.2.12. + - Added support for Python 3.9. + - Fixed bug where amqp message `footer` and `delivery_annotation` were not encoded into the outgoing payload. ## 7.0.0b7 (2020-10-05) diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/_common/message.py b/sdk/servicebus/azure-servicebus/azure/servicebus/_common/message.py index f83159dea6ce..f2b1600b14a2 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/_common/message.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/_common/message.py @@ -60,7 +60,7 @@ class ServiceBusMessage(object): # pylint: disable=too-many-public-methods,too- :keyword str reply_to: The address of an entity to send replies to. :keyword str reply_to_session_id: The session identifier augmenting the `reply_to` address. - :ivar AMQPMessage amqp_annotated_message: Advanced use only. + :ivar AMQPAnnotatedMessage amqp_annotated_message: Advanced use only. The internal AMQP message payload that is sent or received. .. admonition:: Example: @@ -103,7 +103,7 @@ def __init__(self, body, **kwargs): self.partition_key = kwargs.pop("partition_key", None) # If message is the full message, amqp_annotated_message is the "public facing interface" for what we expose. - self.amqp_annotated_message = AMQPMessage(self.message) # type: AMQPMessage + self.amqp_annotated_message = AMQPAnnotatedMessage(self.message) # type: AMQPAnnotatedMessage def __str__(self): return str(self.message) @@ -767,7 +767,7 @@ def locked_until_utc(self): return self._expiry -class AMQPMessage(object): +class AMQPAnnotatedMessage(object): """ The internal AMQP message that this ServiceBusMessage represents. Is read-only. """