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..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 queue description and runtime information + - Get queue properties 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("")