From d07a8fffdce20e9a6f30aaf98afd770aedbe5b4a Mon Sep 17 00:00:00 2001 From: Yunhao Ling Date: Thu, 10 Sep 2020 13:33:21 -0700 Subject: [PATCH 1/2] fix samples --- sdk/servicebus/azure-servicebus/README.md | 2 +- .../async_samples/auto_lock_renew_async.py | 6 +++--- .../samples/async_samples/mgmt_queue_async.py | 20 +++++++++---------- .../receive_deadlettered_messages_async.py | 4 ++-- .../receive_deferred_message_queue_async.py | 2 +- .../async_samples/receive_queue_async.py | 2 +- .../receive_subscription_async.py | 2 +- .../session_send_receive_async.py | 2 +- .../samples/sync_samples/auto_lock_renew.py | 6 +++--- .../samples/sync_samples/mgmt_queue.py | 20 +++++++++---------- .../receive_deadlettered_messages.py | 4 ++-- .../receive_deferred_message_queue.py | 2 +- .../samples/sync_samples/receive_queue.py | 2 +- .../sync_samples/receive_subscription.py | 2 +- .../sync_samples/session_send_receive.py | 2 +- .../tests/stress_tests/test_stress_queues.py | 2 +- 16 files changed, 40 insertions(+), 40 deletions(-) diff --git a/sdk/servicebus/azure-servicebus/README.md b/sdk/servicebus/azure-servicebus/README.md index 26a366a86631..74f2c2e3380a 100644 --- a/sdk/servicebus/azure-servicebus/README.md +++ b/sdk/servicebus/azure-servicebus/README.md @@ -409,7 +409,7 @@ contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additio [cloud_shell]: https://docs.microsoft.com/azure/cloud-shell/overview [cloud_shell_bash]: https://shell.azure.com/bash [pip]: https://pypi.org/project/pip/ -[pypi]: https://pypi.org/project/azure-servicebus/7.0.0b4/ +[pypi]: https://pypi.org/project/azure-servicebus/7.0.0b6/ [python]: https://www.python.org/downloads/ [venv]: https://docs.python.org/3/library/venv.html [virtualenv]: https://virtualenv.pypa.io diff --git a/sdk/servicebus/azure-servicebus/samples/async_samples/auto_lock_renew_async.py b/sdk/servicebus/azure-servicebus/samples/async_samples/auto_lock_renew_async.py index b37f2255c559..60af74906606 100644 --- a/sdk/servicebus/azure-servicebus/samples/async_samples/auto_lock_renew_async.py +++ b/sdk/servicebus/azure-servicebus/samples/async_samples/auto_lock_renew_async.py @@ -38,7 +38,7 @@ async def renew_lock_on_message_received_from_non_sessionful_entity(): renewer = AutoLockRenew() async with servicebus_client.get_queue_receiver(queue_name=QUEUE_NAME, prefetch_count=10) as receiver: - received_msgs = await receiver.receive_messages(max_batch_size=10, max_wait_time=5) + received_msgs = await receiver.receive_messages(max_message_count=10, max_wait_time=5) for msg in received_msgs: # automatically renew the lock on each message for 100 seconds @@ -75,7 +75,7 @@ async def renew_lock_on_session_of_the_sessionful_entity(): renewer.register(receiver.session, timeout=100) print('Register session into AutoLockRenew.') - received_msgs = await receiver.receive_messages(max_batch_size=10, max_wait_time=5) + received_msgs = await receiver.receive_messages(max_message_count=10, max_wait_time=5) await asyncio.sleep(100) # message handling for long period (E.g. application logic) for msg in received_msgs: @@ -104,7 +104,7 @@ async def on_lock_renew_failure_callback(renewable, error): # handle any processing on the message or session that was in progress. print("Intentionally failed to renew lock on {} due to {}".format(renewable, error)) - received_msgs = await receiver.receive_messages(max_batch_size=1, max_wait_time=5) + received_msgs = await receiver.receive_messages(max_message_count=1, max_wait_time=5) for msg in received_msgs: # automatically renew the lock on each message for 120 seconds 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 e73707ed60d6..f6544b1cba02 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 @@ -59,15 +59,15 @@ async def get_and_update_queue(servicebus_mgmt_client): await servicebus_mgmt_client.update_queue(queue_properties) -async def get_queue_runtime_info(servicebus_mgmt_client): - print("-- Get Queue Runtime Info") - queue_runtime_info = await servicebus_mgmt_client.get_queue_runtime_info(QUEUE_NAME) - print("Queue Name:", queue_runtime_info.name) - 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.total_message_count) - print("Please refer to QueueRuntimeInfo from complete available runtime information.") +async def get_queue_runtime_properties(servicebus_mgmt_client): + print("-- Get Queue Runtime Properties") + queue_runtime_properties = await servicebus_mgmt_client.get_queue_runtime_properties(QUEUE_NAME) + print("Queue Name:", queue_runtime_properties.name) + print("Queue Runtime Properties:") + print("Updated at:", queue_runtime_properties.updated_at_utc) + print("Size in Bytes:", queue_runtime_properties.size_in_bytes) + print("Message Count:", queue_runtime_properties.total_message_count) + print("Please refer to QueueRuntimeProperties from complete available runtime properties.") print("") @@ -76,7 +76,7 @@ async def main(): await create_queue(servicebus_mgmt_client) await list_queues(servicebus_mgmt_client) await get_and_update_queue(servicebus_mgmt_client) - await get_queue_runtime_info(servicebus_mgmt_client) + await get_queue_runtime_properties(servicebus_mgmt_client) await delete_queue(servicebus_mgmt_client) loop = asyncio.get_event_loop() diff --git a/sdk/servicebus/azure-servicebus/samples/async_samples/receive_deadlettered_messages_async.py b/sdk/servicebus/azure-servicebus/samples/async_samples/receive_deadlettered_messages_async.py index f77310a957b2..7a1557907ca4 100644 --- a/sdk/servicebus/azure-servicebus/samples/async_samples/receive_deadlettered_messages_async.py +++ b/sdk/servicebus/azure-servicebus/samples/async_samples/receive_deadlettered_messages_async.py @@ -33,7 +33,7 @@ async def main(): print('dead lettering messages') receiver = servicebus_client.get_queue_receiver(queue_name=QUEUE_NAME) async with receiver: - received_msgs = await receiver.receive_messages(max_batch_size=10, max_wait_time=5) + received_msgs = await receiver.receive_messages(max_message_count=10, max_wait_time=5) for msg in received_msgs: print(str(msg)) await msg.dead_letter() @@ -43,7 +43,7 @@ async def main(): sub_queue=SubQueue.DeadLetter, prefetch_count=10) async with dlq_receiver: - received_msgs = await dlq_receiver.receive_messages(max_batch_size=10, max_wait_time=5) + received_msgs = await dlq_receiver.receive_messages(max_message_count=10, max_wait_time=5) for msg in received_msgs: print(str(msg)) await msg.complete() diff --git a/sdk/servicebus/azure-servicebus/samples/async_samples/receive_deferred_message_queue_async.py b/sdk/servicebus/azure-servicebus/samples/async_samples/receive_deferred_message_queue_async.py index b228a5a64507..76a55a185c77 100644 --- a/sdk/servicebus/azure-servicebus/samples/async_samples/receive_deferred_message_queue_async.py +++ b/sdk/servicebus/azure-servicebus/samples/async_samples/receive_deferred_message_queue_async.py @@ -32,7 +32,7 @@ async def main(): receiver = servicebus_client.get_queue_receiver(queue_name=QUEUE_NAME) async with receiver: - received_msgs = await receiver.receive_messages(max_batch_size=10, max_wait_time=5) + received_msgs = await receiver.receive_messages(max_message_count=10, max_wait_time=5) deferred_sequenced_numbers = [] for msg in received_msgs: print("Deferring msg: {}".format(str(msg))) diff --git a/sdk/servicebus/azure-servicebus/samples/async_samples/receive_queue_async.py b/sdk/servicebus/azure-servicebus/samples/async_samples/receive_queue_async.py index d377565704b0..a510160a713e 100644 --- a/sdk/servicebus/azure-servicebus/samples/async_samples/receive_queue_async.py +++ b/sdk/servicebus/azure-servicebus/samples/async_samples/receive_queue_async.py @@ -25,7 +25,7 @@ async def main(): async with servicebus_client: receiver = servicebus_client.get_queue_receiver(queue_name=QUEUE_NAME) async with receiver: - received_msgs = await receiver.receive_messages(max_batch_size=10, max_wait_time=5) + received_msgs = await receiver.receive_messages(max_message_count=10, max_wait_time=5) for msg in received_msgs: print(str(msg)) await msg.complete() diff --git a/sdk/servicebus/azure-servicebus/samples/async_samples/receive_subscription_async.py b/sdk/servicebus/azure-servicebus/samples/async_samples/receive_subscription_async.py index a98d74aa6e02..fff5f8dc0cd4 100644 --- a/sdk/servicebus/azure-servicebus/samples/async_samples/receive_subscription_async.py +++ b/sdk/servicebus/azure-servicebus/samples/async_samples/receive_subscription_async.py @@ -29,7 +29,7 @@ async def main(): subscription_name=SUBSCRIPTION_NAME ) async with receiver: - received_msgs = await receiver.receive_messages(max_batch_size=10, max_wait_time=5) + received_msgs = await receiver.receive_messages(max_message_count=10, max_wait_time=5) for msg in received_msgs: print(str(msg)) await msg.complete() diff --git a/sdk/servicebus/azure-servicebus/samples/async_samples/session_send_receive_async.py b/sdk/servicebus/azure-servicebus/samples/async_samples/session_send_receive_async.py index 3e9ce62f3f88..e7714280bfa4 100644 --- a/sdk/servicebus/azure-servicebus/samples/async_samples/session_send_receive_async.py +++ b/sdk/servicebus/azure-servicebus/samples/async_samples/session_send_receive_async.py @@ -47,7 +47,7 @@ async def receive_batch_messages(receiver): session = receiver.session await session.set_state("START") print("Session state:", await session.get_state()) - received_msgs = await receiver.receive_messages(max_batch_size=10, max_wait_time=5) + received_msgs = await receiver.receive_messages(max_message_count=10, max_wait_time=5) for msg in received_msgs: print(str(msg)) await msg.complete() diff --git a/sdk/servicebus/azure-servicebus/samples/sync_samples/auto_lock_renew.py b/sdk/servicebus/azure-servicebus/samples/sync_samples/auto_lock_renew.py index 00d0cf970bce..46d4c1436877 100644 --- a/sdk/servicebus/azure-servicebus/samples/sync_samples/auto_lock_renew.py +++ b/sdk/servicebus/azure-servicebus/samples/sync_samples/auto_lock_renew.py @@ -37,7 +37,7 @@ def renew_lock_on_message_received_from_non_sessionful_entity(): renewer = AutoLockRenew() with servicebus_client.get_queue_receiver(queue_name=QUEUE_NAME, prefetch_count=10) as receiver: - received_msgs = receiver.receive_messages(max_batch_size=10, max_wait_time=5) + received_msgs = receiver.receive_messages(max_message_count=10, max_wait_time=5) for msg in received_msgs: # automatically renew the lock on each message for 100 seconds @@ -75,7 +75,7 @@ def renew_lock_on_session_of_the_sessionful_entity(): renewer.register(receiver.session, timeout=100) print('Register session into AutoLockRenew.') - received_msgs = receiver.receive_messages(max_batch_size=10, max_wait_time=5) + received_msgs = receiver.receive_messages(max_message_count=10, max_wait_time=5) time.sleep(100) # message handling for long period (E.g. application logic) for msg in received_msgs: @@ -107,7 +107,7 @@ def on_lock_renew_failure_callback(renewable, error): # handle any processing on the message or session that was in progress. print("Intentionally failed to renew lock on {} due to {}".format(renewable, error)) - received_msgs = receiver.receive_messages(max_batch_size=1, max_wait_time=5) + received_msgs = receiver.receive_messages(max_message_count=1, max_wait_time=5) for msg in received_msgs: # automatically renew the lock on each message for 120 seconds 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 2302bd71b045..733a301ecdfc 100644 --- a/sdk/servicebus/azure-servicebus/samples/sync_samples/mgmt_queue.py +++ b/sdk/servicebus/azure-servicebus/samples/sync_samples/mgmt_queue.py @@ -58,15 +58,15 @@ def get_and_update_queue(servicebus_mgmt_client): servicebus_mgmt_client.update_queue(queue_properties) -def get_queue_runtime_info(servicebus_mgmt_client): - print("-- Get Queue Runtime Info") - queue_runtime_info = servicebus_mgmt_client.get_queue_runtime_info(QUEUE_NAME) - print("Queue Name:", queue_runtime_info.name) - 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.total_message_count) - print("Please refer to QueueRuntimeInfo from complete available runtime information.") +def get_queue_runtime_properties(servicebus_mgmt_client): + print("-- Get Queue Runtime Properties") + get_queue_runtime_properties = servicebus_mgmt_client.get_queue_runtime_properties(QUEUE_NAME) + print("Queue Name:", get_queue_runtime_properties.name) + print("Queue Runtime Properties:") + print("Updated at:", get_queue_runtime_properties.updated_at_utc) + print("Size in Bytes:", get_queue_runtime_properties.size_in_bytes) + print("Message Count:", get_queue_runtime_properties.total_message_count) + print("Please refer to QueueRuntimeProperties from complete available runtime properties.") print("") @@ -74,5 +74,5 @@ def get_queue_runtime_info(servicebus_mgmt_client): create_queue(servicebus_mgmt_client) list_queues(servicebus_mgmt_client) get_and_update_queue(servicebus_mgmt_client) - get_queue_runtime_info(servicebus_mgmt_client) + get_queue_runtime_properties(servicebus_mgmt_client) delete_queue(servicebus_mgmt_client) diff --git a/sdk/servicebus/azure-servicebus/samples/sync_samples/receive_deadlettered_messages.py b/sdk/servicebus/azure-servicebus/samples/sync_samples/receive_deadlettered_messages.py index 03274d368fe1..a3be4d5c2691 100644 --- a/sdk/servicebus/azure-servicebus/samples/sync_samples/receive_deadlettered_messages.py +++ b/sdk/servicebus/azure-servicebus/samples/sync_samples/receive_deadlettered_messages.py @@ -28,7 +28,7 @@ print('dead lettering messages') receiver = servicebus_client.get_queue_receiver(queue_name=QUEUE_NAME) with receiver: - received_msgs = receiver.receive_messages(max_batch_size=10, max_wait_time=5) + received_msgs = receiver.receive_messages(max_message_count=10, max_wait_time=5) for msg in received_msgs: print(str(msg)) msg.dead_letter() @@ -36,7 +36,7 @@ print('receiving deadlettered messages') dlq_receiver = servicebus_client.get_queue_receiver(queue_name=QUEUE_NAME, sub_queue=SubQueue.DeadLetter) with dlq_receiver: - received_msgs = dlq_receiver.receive_messages(max_batch_size=10, max_wait_time=5) + received_msgs = dlq_receiver.receive_messages(max_message_count=10, max_wait_time=5) for msg in received_msgs: print(str(msg)) msg.complete() diff --git a/sdk/servicebus/azure-servicebus/samples/sync_samples/receive_deferred_message_queue.py b/sdk/servicebus/azure-servicebus/samples/sync_samples/receive_deferred_message_queue.py index e92d93ba2970..d532c7fefaf4 100644 --- a/sdk/servicebus/azure-servicebus/samples/sync_samples/receive_deferred_message_queue.py +++ b/sdk/servicebus/azure-servicebus/samples/sync_samples/receive_deferred_message_queue.py @@ -27,7 +27,7 @@ receiver = servicebus_client.get_queue_receiver(queue_name=QUEUE_NAME) with receiver: - received_msgs = receiver.receive_messages(max_batch_size=10, max_wait_time=5) + received_msgs = receiver.receive_messages(max_message_count=10, max_wait_time=5) deferred_sequenced_numbers = [] for msg in received_msgs: print("Deferring msg: {}".format(str(msg))) diff --git a/sdk/servicebus/azure-servicebus/samples/sync_samples/receive_queue.py b/sdk/servicebus/azure-servicebus/samples/sync_samples/receive_queue.py index 746a4f6d0469..50eedb8a9ca8 100644 --- a/sdk/servicebus/azure-servicebus/samples/sync_samples/receive_queue.py +++ b/sdk/servicebus/azure-servicebus/samples/sync_samples/receive_queue.py @@ -22,7 +22,7 @@ with servicebus_client: receiver = servicebus_client.get_queue_receiver(queue_name=QUEUE_NAME) with receiver: - received_msgs = receiver.receive_messages(max_batch_size=10, max_wait_time=5) + received_msgs = receiver.receive_messages(max_message_count=10, max_wait_time=5) for msg in received_msgs: print(str(msg)) msg.complete() diff --git a/sdk/servicebus/azure-servicebus/samples/sync_samples/receive_subscription.py b/sdk/servicebus/azure-servicebus/samples/sync_samples/receive_subscription.py index 38def12f8940..a43921e11760 100644 --- a/sdk/servicebus/azure-servicebus/samples/sync_samples/receive_subscription.py +++ b/sdk/servicebus/azure-servicebus/samples/sync_samples/receive_subscription.py @@ -26,7 +26,7 @@ subscription_name=SUBSCRIPTION_NAME ) with receiver: - received_msgs = receiver.receive_messages(max_batch_size=10, max_wait_time=5) + received_msgs = receiver.receive_messages(max_message_count=10, max_wait_time=5) for msg in received_msgs: print(str(msg)) msg.complete() diff --git a/sdk/servicebus/azure-servicebus/samples/sync_samples/session_send_receive.py b/sdk/servicebus/azure-servicebus/samples/sync_samples/session_send_receive.py index 4b38ecffc8d7..b31fc97a8e0d 100644 --- a/sdk/servicebus/azure-servicebus/samples/sync_samples/session_send_receive.py +++ b/sdk/servicebus/azure-servicebus/samples/sync_samples/session_send_receive.py @@ -45,7 +45,7 @@ def receive_batch_message(receiver): session = receiver.session session.set_state("START") print("Session state:", session.get_state()) - received_msgs = receiver.receive_messages(max_batch_size=10, max_wait_time=5) + received_msgs = receiver.receive_messages(max_message_count=10, max_wait_time=5) for msg in received_msgs: print(str(msg)) msg.complete() diff --git a/sdk/servicebus/azure-servicebus/tests/stress_tests/test_stress_queues.py b/sdk/servicebus/azure-servicebus/tests/stress_tests/test_stress_queues.py index f98c3baab1c9..ad9617acfc96 100644 --- a/sdk/servicebus/azure-servicebus/tests/stress_tests/test_stress_queues.py +++ b/sdk/servicebus/azure-servicebus/tests/stress_tests/test_stress_queues.py @@ -71,7 +71,7 @@ def test_stress_queue_batch_send_and_receive(self, servicebus_namespace_connecti stress_test = StressTestRunner(senders = [sb_client.get_queue_sender(servicebus_queue.name)], receivers = [sb_client.get_queue_receiver(servicebus_queue.name)], - duration=timedelta(seconds=60), + duration=timedelta(seconds=3600 * 24 * 3), send_batch_size=5) result = stress_test.Run() From f7d789bda484203f559475150f3b18eceda9d6cf Mon Sep 17 00:00:00 2001 From: Yunhao Ling Date: Thu, 10 Sep 2020 13:36:37 -0700 Subject: [PATCH 2/2] revert duration --- .../azure-servicebus/tests/stress_tests/test_stress_queues.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/servicebus/azure-servicebus/tests/stress_tests/test_stress_queues.py b/sdk/servicebus/azure-servicebus/tests/stress_tests/test_stress_queues.py index ad9617acfc96..f98c3baab1c9 100644 --- a/sdk/servicebus/azure-servicebus/tests/stress_tests/test_stress_queues.py +++ b/sdk/servicebus/azure-servicebus/tests/stress_tests/test_stress_queues.py @@ -71,7 +71,7 @@ def test_stress_queue_batch_send_and_receive(self, servicebus_namespace_connecti stress_test = StressTestRunner(senders = [sb_client.get_queue_sender(servicebus_queue.name)], receivers = [sb_client.get_queue_receiver(servicebus_queue.name)], - duration=timedelta(seconds=3600 * 24 * 3), + duration=timedelta(seconds=60), send_batch_size=5) result = stress_test.Run()