From 4bf82809714e57af2f3fe947592132268b5e3bc8 Mon Sep 17 00:00:00 2001 From: "Adam Ling (MSFT)" Date: Thu, 24 Jun 2021 13:49:23 -0700 Subject: [PATCH 1/3] fix utc and milliseconds issue --- sdk/servicebus/azure-servicebus/CHANGELOG.md | 6 ++++-- .../azure-servicebus/azure/servicebus/_common/message.py | 2 +- .../azure-servicebus/azure/servicebus/_common/utils.py | 6 +++--- .../azure-servicebus/azure/servicebus/amqp/_amqp_message.py | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/sdk/servicebus/azure-servicebus/CHANGELOG.md b/sdk/servicebus/azure-servicebus/CHANGELOG.md index c523940f080b..dffdeceb4c87 100644 --- a/sdk/servicebus/azure-servicebus/CHANGELOG.md +++ b/sdk/servicebus/azure-servicebus/CHANGELOG.md @@ -2,9 +2,11 @@ ## 7.3.1 (Unreleased) -**Bug Fixes** +### Fixed -* Fixed a bug that when setting `ServiceBusMessage.partition_key`, input value should be not validated against `session_id` of None (PR #19233, thanks @bishnu-shb). +- Fixed a bug that when setting `ServiceBusMessage.partition_key`, input value should be not validated against `session_id` of None (PR #19233, thanks @bishnu-shb). +- Fixed a bug that setting `ServiceBusMessage.time_to_live` causes OverflowError error on Ubuntu 20.04. +- Fixed a bug that `AmqpAnnotatedProperties.creation_time` and `AmqpAnnotatedProperties.absolute_expiry_time` should be calculated in the unit of milliseconds instead of seconds. ## 7.3.0 (2021-06-08) diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/_common/message.py b/sdk/servicebus/azure-servicebus/azure/servicebus/_common/message.py index f5ed0ace07cf..3d92b085dece 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/_common/message.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/_common/message.py @@ -355,7 +355,7 @@ def time_to_live(self, value): self._raw_amqp_message.header.time_to_live != MAX_DURATION_VALUE: if not self._raw_amqp_message.properties: self._raw_amqp_message.properties = AmqpMessageProperties() - self._raw_amqp_message.properties.creation_time = int(time.mktime(utc_now().timetuple())) + self._raw_amqp_message.properties.creation_time = int(time.mktime(utc_now().timetuple())) * 1000 self._raw_amqp_message.properties.absolute_expiry_time = min( MAX_ABSOLUTE_EXPIRY_TIME, self._raw_amqp_message.properties.creation_time + self._raw_amqp_message.header.time_to_live diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/_common/utils.py b/sdk/servicebus/azure-servicebus/azure/servicebus/_common/utils.py index 9b99db116d9b..6505b09058f6 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/_common/utils.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/_common/utils.py @@ -24,7 +24,7 @@ cast ) from contextlib import contextmanager -from msrest.serialization import UTC +from msrest.serialization import TZ_UTC try: from urlparse import urlparse @@ -81,11 +81,11 @@ def utc_from_timestamp(timestamp): - return datetime.datetime.fromtimestamp(timestamp, tz=UTC()) + return datetime.datetime.fromtimestamp(timestamp, tz=TZ_UTC) def utc_now(): - return datetime.datetime.now(UTC()) + return datetime.datetime.now(TZ_UTC) def build_uri(address, entity): diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/amqp/_amqp_message.py b/sdk/servicebus/azure-servicebus/azure/servicebus/amqp/_amqp_message.py index c134bfa86c26..aeafe9457f5e 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/amqp/_amqp_message.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/amqp/_amqp_message.py @@ -8,7 +8,7 @@ from datetime import datetime from typing import Optional, Any, cast, Mapping -from msrest.serialization import UTC +from msrest.serialization import TZ_UTC import uamqp from ._constants import AMQP_MESSAGE_BODY_TYPE_MAP, AmqpMessageBodyType @@ -229,7 +229,7 @@ def _to_outgoing_amqp_message(self): message_header.priority = self.header.priority if self.header.time_to_live and self.header.time_to_live != MAX_DURATION_VALUE: ttl_set = True - creation_time_from_ttl = int(time.mktime(datetime.now(UTC()).timetuple())) + creation_time_from_ttl = int(time.mktime(datetime.now(TZ_UTC).timetuple())) * 1000 absolute_expiry_time_from_ttl = int(min( MAX_ABSOLUTE_EXPIRY_TIME, creation_time_from_ttl + self.header.time_to_live From e012afbf45ee8036a596415bf9124a9db26ac03b Mon Sep 17 00:00:00 2001 From: "Adam Ling (MSFT)" Date: Fri, 25 Jun 2021 02:18:50 -0700 Subject: [PATCH 2/3] fix python2.7 --- .../azure-servicebus/azure/servicebus/amqp/_amqp_message.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/amqp/_amqp_message.py b/sdk/servicebus/azure-servicebus/azure/servicebus/amqp/_amqp_message.py index aeafe9457f5e..9484262c5cea 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/amqp/_amqp_message.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/amqp/_amqp_message.py @@ -229,7 +229,7 @@ def _to_outgoing_amqp_message(self): message_header.priority = self.header.priority if self.header.time_to_live and self.header.time_to_live != MAX_DURATION_VALUE: ttl_set = True - creation_time_from_ttl = int(time.mktime(datetime.now(TZ_UTC).timetuple())) * 1000 + creation_time_from_ttl = int(time.mktime(datetime.now(TZ_UTC).timetuple()) * 1000) absolute_expiry_time_from_ttl = int(min( MAX_ABSOLUTE_EXPIRY_TIME, creation_time_from_ttl + self.header.time_to_live From 814e05c3c689286b8ac8ce4bcb8cbe5d950194ed Mon Sep 17 00:00:00 2001 From: "Adam Ling (MSFT)" Date: Mon, 28 Jun 2021 10:22:57 -0700 Subject: [PATCH 3/3] update uamqp dependency to 1.4.1 --- sdk/servicebus/azure-servicebus/CHANGELOG.md | 2 ++ sdk/servicebus/azure-servicebus/setup.py | 2 +- shared_requirements.txt | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sdk/servicebus/azure-servicebus/CHANGELOG.md b/sdk/servicebus/azure-servicebus/CHANGELOG.md index dffdeceb4c87..e9d53ef6b014 100644 --- a/sdk/servicebus/azure-servicebus/CHANGELOG.md +++ b/sdk/servicebus/azure-servicebus/CHANGELOG.md @@ -7,6 +7,8 @@ - Fixed a bug that when setting `ServiceBusMessage.partition_key`, input value should be not validated against `session_id` of None (PR #19233, thanks @bishnu-shb). - Fixed a bug that setting `ServiceBusMessage.time_to_live` causes OverflowError error on Ubuntu 20.04. - Fixed a bug that `AmqpAnnotatedProperties.creation_time` and `AmqpAnnotatedProperties.absolute_expiry_time` should be calculated in the unit of milliseconds instead of seconds. +- Updated uAMQP dependency to 1.4.1. + - Fixed a bug that attributes creation_time, absolute_expiry_time and group_sequence on MessageProperties should be compatible with integer types on Python 2.7. ## 7.3.0 (2021-06-08) diff --git a/sdk/servicebus/azure-servicebus/setup.py b/sdk/servicebus/azure-servicebus/setup.py index e71c875afb88..08f3a9c2558f 100644 --- a/sdk/servicebus/azure-servicebus/setup.py +++ b/sdk/servicebus/azure-servicebus/setup.py @@ -79,7 +79,7 @@ 'azure', ]), install_requires=[ - "uamqp>=1.4.0,<2.0.0", + "uamqp>=1.4.1,<2.0.0", 'azure-common~=1.1', 'msrest>=0.6.17,<2.0.0', 'azure-core<2.0.0,>=1.14.0', diff --git a/shared_requirements.txt b/shared_requirements.txt index bbd94f34c767..cc32b0303bb9 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -174,7 +174,7 @@ opentelemetry-sdk<2.0.0,>=1.0.0 #override azure-eventhub uamqp>=1.4.0,<2.0.0 #override azure-appconfiguration msrest>=0.6.10 #override azure-mgmt-appconfiguration msrest>=0.6.21 -#override azure-servicebus uamqp>=1.4.0,<2.0.0 +#override azure-servicebus uamqp>=1.4.1,<2.0.0 #override azure-servicebus msrest>=0.6.17,<2.0.0 #override azure-servicebus azure-core<2.0.0,>=1.14.0 #override azure-servicefabric msrest>=0.6.21