From a565e3f7f2e4dcb88a2cd7b6610166a81673e94a Mon Sep 17 00:00:00 2001 From: Yijun Xie <48257664+YijunXieMS@users.noreply.github.com> Date: Mon, 10 Aug 2020 10:45:11 -0700 Subject: [PATCH 1/2] Update sample for QueueProperties --- .../azure-servicebus/samples/README.md | 2 +- .../samples/async_samples/mgmt_queue_async.py | 33 ++++++++----------- .../samples/sync_samples/mgmt_queue.py | 32 ++++++++---------- 3 files changed, 27 insertions(+), 40 deletions(-) diff --git a/sdk/servicebus/azure-servicebus/samples/README.md b/sdk/servicebus/azure-servicebus/samples/README.md index 9f9b47b4b25d..5745df3efec8 100644 --- a/sdk/servicebus/azure-servicebus/samples/README.md +++ b/sdk/servicebus/azure-servicebus/samples/README.md @@ -57,7 +57,7 @@ Both [sync version](./sync_samples) and [async version](./async_samples) of samp - Delete a queue - Update a queue - List queues - - Get queue description + - Get queue properties - Get queue runtime information diff --git a/sdk/servicebus/azure-servicebus/samples/async_samples/mgmt_queue_async.py b/sdk/servicebus/azure-servicebus/samples/async_samples/mgmt_queue_async.py index 37704729d95b..e022b76270ba 100644 --- a/sdk/servicebus/azure-servicebus/samples/async_samples/mgmt_queue_async.py +++ b/sdk/servicebus/azure-servicebus/samples/async_samples/mgmt_queue_async.py @@ -8,7 +8,7 @@ """ Example to show managing queue entities under a ServiceBus Namespace asynchronously, including - Create a queue - - Get queue description and runtime information + - Get a queue and runtime information - Update a queue - Delete a queue - List queues under the given ServiceBus Namespace @@ -18,7 +18,6 @@ import os import asyncio -from azure.servicebus.management import QueueDescription from azure.servicebus.aio.management import ServiceBusManagementClient CONNECTION_STR = os.environ['SERVICE_BUS_CONNECTION_STR'] @@ -27,13 +26,7 @@ async def create_queue(servicebus_mgmt_client): print("-- Create Queue") - queue_description = QueueDescription(QUEUE_NAME) - # You can adjust the settings of a queue when creating. - # Please refer to the QueueDescription class for available settings. - queue_description.max_delivery_count = 10 - queue_description.dead_lettering_on_message_expiration = True - - await servicebus_mgmt_client.create_queue(queue_description) + await servicebus_mgmt_client.create_queue(QUEUE_NAME, max_delivery_count=10, dead_lettering_on_message_expiration=True) print("Queue {} is created.".format(QUEUE_NAME)) print("") @@ -47,23 +40,23 @@ async def delete_queue(servicebus_mgmt_client): async def list_queues(servicebus_mgmt_client): print("-- List Queues") - async for queue_description in servicebus_mgmt_client.list_queues(): - print("Queue Name:", queue_description.name) + async for queue_properties in servicebus_mgmt_client.list_queues(): + print("Queue Name:", queue_properties.name) print("") async def get_and_update_queue(servicebus_mgmt_client): print("-- Get and Update Queue") - queue_description = await servicebus_mgmt_client.get_queue(QUEUE_NAME) - print("Queue Name:", queue_description.name) + queue_properties = await servicebus_mgmt_client.get_queue(QUEUE_NAME) + print("Queue Name:", queue_properties.name) print("Queue Settings:") - print("Auto Delete on Idle:", queue_description.auto_delete_on_idle) - print("Default Message Time to Live:", queue_description.default_message_time_to_live) - print("Dead Lettering on Message Expiration:", queue_description.dead_lettering_on_message_expiration) - print("Please refer to QueueDescription for complete available settings.") + print("Auto Delete on Idle:", queue_properties.auto_delete_on_idle) + print("Default Message Time to Live:", queue_properties.default_message_time_to_live) + print("Dead Lettering on Message Expiration:", queue_properties.dead_lettering_on_message_expiration) + print("Please refer to QueueProperties for complete available settings.") print("") - queue_description.max_delivery_count = 5 - await servicebus_mgmt_client.update_queue(queue_description) + queue_properties.max_delivery_count = 5 + await servicebus_mgmt_client.update_queue(queue_properties) async def get_queue_runtime_info(servicebus_mgmt_client): @@ -73,7 +66,7 @@ async def get_queue_runtime_info(servicebus_mgmt_client): print("Queue Runtime Info:") print("Updated at:", queue_runtime_info.updated_at) print("Size in Bytes:", queue_runtime_info.size_in_bytes) - print("Message Count:", queue_runtime_info.message_count) + print("Message Count:", queue_runtime_info.total_message_count) print("Please refer to QueueRuntimeInfo from complete available runtime information.") print("") diff --git a/sdk/servicebus/azure-servicebus/samples/sync_samples/mgmt_queue.py b/sdk/servicebus/azure-servicebus/samples/sync_samples/mgmt_queue.py index f91d798a4103..f9a834e008bf 100644 --- a/sdk/servicebus/azure-servicebus/samples/sync_samples/mgmt_queue.py +++ b/sdk/servicebus/azure-servicebus/samples/sync_samples/mgmt_queue.py @@ -8,7 +8,7 @@ """ Example to show managing queue entities under a ServiceBus Namespace, including - Create a queue - - Get queue description and runtime information + - Get queue properties and runtime information - Update a queue - Delete a queue - List queues under the given ServiceBus Namespace @@ -17,7 +17,7 @@ # pylint: disable=C0111 import os -from azure.servicebus.management import ServiceBusManagementClient, QueueDescription +from azure.servicebus.management import ServiceBusManagementClient CONNECTION_STR = os.environ['SERVICE_BUS_CONNECTION_STR'] QUEUE_NAME = "sb_mgmt_demo_queue" @@ -25,13 +25,7 @@ def create_queue(servicebus_mgmt_client): print("-- Create Queue") - queue_description = QueueDescription(QUEUE_NAME) - # You can adjust the settings of a queue when creating. - # Please refer to the QueueDescription class for available settings. - queue_description.max_delivery_count = 10 - queue_description.dead_lettering_on_message_expiration = True - - servicebus_mgmt_client.create_queue(queue_description) + servicebus_mgmt_client.create_queue(QUEUE_NAME, max_delivery_count=10, dead_lettering_on_message_expiration=True) print("Queue {} is created.".format(QUEUE_NAME)) print("") @@ -45,23 +39,23 @@ def delete_queue(servicebus_mgmt_client): def list_queues(servicebus_mgmt_client): print("-- List Queues") - for queue_description in servicebus_mgmt_client.list_queues(): - print("Queue Name:", queue_description.name) + for queue_properties in servicebus_mgmt_client.list_queues(): + print("Queue Name:", queue_properties.name) print("") def get_and_update_queue(servicebus_mgmt_client): print("-- Get and Update Queue") - queue_description = servicebus_mgmt_client.get_queue(QUEUE_NAME) - print("Queue Name:", queue_description.name) + queue_properties = servicebus_mgmt_client.get_queue(QUEUE_NAME) + print("Queue Name:", queue_properties.name) print("Queue Settings:") - print("Auto Delete on Idle:", queue_description.auto_delete_on_idle) - print("Default Message Time to Live:", queue_description.default_message_time_to_live) - print("Dead Lettering on Message Expiration:", queue_description.dead_lettering_on_message_expiration) + print("Auto Delete on Idle:", queue_properties.auto_delete_on_idle) + print("Default Message Time to Live:", queue_properties.default_message_time_to_live) + print("Dead Lettering on Message Expiration:", queue_properties.dead_lettering_on_message_expiration) print("Please refer to QueueDescription for complete available settings.") print("") - queue_description.max_delivery_count = 5 - servicebus_mgmt_client.update_queue(queue_description) + queue_properties.max_delivery_count = 5 + servicebus_mgmt_client.update_queue(queue_properties) def get_queue_runtime_info(servicebus_mgmt_client): @@ -71,7 +65,7 @@ def get_queue_runtime_info(servicebus_mgmt_client): print("Queue Runtime Info:") print("Updated at:", queue_runtime_info.updated_at) print("Size in Bytes:", queue_runtime_info.size_in_bytes) - print("Message Count:", queue_runtime_info.message_count) + print("Message Count:", queue_runtime_info.total_message_count) print("Please refer to QueueRuntimeInfo from complete available runtime information.") print("") From 011d42daf6ba6e4eb390118293eec87baa262127 Mon Sep 17 00:00:00 2001 From: Yijun Xie <48257664+YijunXieMS@users.noreply.github.com> Date: Mon, 10 Aug 2020 11:40:30 -0700 Subject: [PATCH 2/2] small wording change --- .../azure-servicebus/samples/async_samples/mgmt_queue_async.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/servicebus/azure-servicebus/samples/async_samples/mgmt_queue_async.py b/sdk/servicebus/azure-servicebus/samples/async_samples/mgmt_queue_async.py index e022b76270ba..becc4afe7f20 100644 --- a/sdk/servicebus/azure-servicebus/samples/async_samples/mgmt_queue_async.py +++ b/sdk/servicebus/azure-servicebus/samples/async_samples/mgmt_queue_async.py @@ -8,7 +8,7 @@ """ Example to show managing queue entities under a ServiceBus Namespace asynchronously, including - Create a queue - - Get a queue and runtime information + - Get queue properties and runtime information - Update a queue - Delete a queue - List queues under the given ServiceBus Namespace