diff --git a/sdk/servicebus/azure-servicebus/samples/README.md b/sdk/servicebus/azure-servicebus/samples/README.md index 8283fb679d0c..d6bade57191c 100644 --- a/sdk/servicebus/azure-servicebus/samples/README.md +++ b/sdk/servicebus/azure-servicebus/samples/README.md @@ -85,6 +85,8 @@ Both [sync version](https://github.com/Azure/azure-sdk-for-python/tree/master/sd - List rule - Get rule properties - [failure_and_recovery.py](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/servicebus/azure-servicebus/samples/sync_samples/failure_and_recovery.py) - A demonstration of potential failure modes from an end-to-end send receive flow, as well as possible recovery patterns. +- [deadletter_messages_and_correct.py](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/servicebus/azure-servicebus/samples/sync_samples/deadletter_messages_and_correct.py) ([async_version](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/servicebus/azure-servicebus/samples/async_samples/deadletter_messages_and_correct_async.py)) - Comprehensive example of moving messages to the dead-letter queue, retrieving messages from it, and resubmitting corrected messages back into main queue. +- [topic_subscription_with_rule_operations.py](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/servicebus/azure-servicebus/samples/sync_samples/topic_subscription_with_rule_operations.py) ([async_version](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/servicebus/azure-servicebus/samples/async_samples/topic_subscription_with_rule_operations_async.py)) - Example to manage rules on topic subscriptions and to explore different forms of subscription filters. ## Prerequisites - Python 2.7, 3.6 or later. diff --git a/sdk/servicebus/azure-servicebus/samples/async_samples/deadletter_messages_and_correct_async.py b/sdk/servicebus/azure-servicebus/samples/async_samples/deadletter_messages_and_correct_async.py index 32c9c0ad64c8..e4fed7fcd718 100644 --- a/sdk/servicebus/azure-servicebus/samples/async_samples/deadletter_messages_and_correct_async.py +++ b/sdk/servicebus/azure-servicebus/samples/async_samples/deadletter_messages_and_correct_async.py @@ -50,7 +50,7 @@ async def exceed_max_delivery(servicebus_client): received_msgs = await receiver.receive_messages(max_wait_time=5) async with dlq_receiver: - received_msgs = await dlq_receiver.receive_messages(max_message_count=10) + received_msgs = await dlq_receiver.receive_messages(max_message_count=10, max_wait_time=5) for msg in received_msgs: print("Deadletter message:") print(msg) @@ -59,7 +59,7 @@ async def exceed_max_delivery(servicebus_client): async def receive_messages(servicebus_client): receiver = servicebus_client.get_queue_receiver(queue_name=QUEUE_NAME) async with receiver: - received_msgs = await receiver.receive_messages(max_message_count=10) + received_msgs = await receiver.receive_messages(max_message_count=10, max_wait_time=5) for msg in received_msgs: if msg.subject and msg.subject == "Good": await receiver.complete_message(msg) @@ -77,7 +77,7 @@ async def fix_deadletters(servicebus_client): sub_queue=ServiceBusSubQueue.DEAD_LETTER) msgs_to_send = [] async with dlq_receiver: - received_dlq_msgs = await dlq_receiver.receive_messages(max_message_count=10) + received_dlq_msgs = await dlq_receiver.receive_messages(max_message_count=10, max_wait_time=5) for msg in received_dlq_msgs: if msg.subject and msg.subject == "Bad": msg_copy = ServiceBusMessage(str(msg), subject="Good") @@ -88,7 +88,7 @@ async def fix_deadletters(servicebus_client): print("Resending fixed messages") await sender.send_messages(msgs_to_send) async with receiver: - received_msgs = await receiver.receive_messages(max_message_count=10) + received_msgs = await receiver.receive_messages(max_message_count=10, max_wait_time=5) for msg in received_msgs: if msg.subject and msg.subject == "Good": print("Received fixed message: Body={}, Subject={}".format(next(msg.body), msg.subject)) diff --git a/sdk/servicebus/azure-servicebus/samples/sync_samples/deadletter_messages_and_correct.py b/sdk/servicebus/azure-servicebus/samples/sync_samples/deadletter_messages_and_correct.py index df60fbeb18aa..d6fb6a88b93d 100644 --- a/sdk/servicebus/azure-servicebus/samples/sync_samples/deadletter_messages_and_correct.py +++ b/sdk/servicebus/azure-servicebus/samples/sync_samples/deadletter_messages_and_correct.py @@ -48,7 +48,7 @@ def exceed_max_delivery(servicebus_client): received_msgs = receiver.receive_messages(max_wait_time=5) with dlq_receiver: - received_msgs = dlq_receiver.receive_messages(max_message_count=10) + received_msgs = dlq_receiver.receive_messages(max_message_count=10, max_wait_time=5) for msg in received_msgs: print("Deadletter message:") print(msg) @@ -57,7 +57,7 @@ def exceed_max_delivery(servicebus_client): def receive_messages(servicebus_client): receiver = servicebus_client.get_queue_receiver(queue_name=QUEUE_NAME) with receiver: - received_msgs = receiver.receive_messages(max_message_count=10) + received_msgs = receiver.receive_messages(max_message_count=10, max_wait_time=5) for msg in received_msgs: if msg.subject and msg.subject == "Good": receiver.complete_message(msg) @@ -75,7 +75,7 @@ def fix_deadletters(servicebus_client): sub_queue=ServiceBusSubQueue.DEAD_LETTER) msgs_to_send = [] with dlq_receiver: - received_dlq_msgs = dlq_receiver.receive_messages(max_message_count=10) + received_dlq_msgs = dlq_receiver.receive_messages(max_message_count=10, max_wait_time=5) for msg in received_dlq_msgs: if msg.subject and msg.subject == "Bad": msg_copy = ServiceBusMessage(str(msg), subject="Good") @@ -86,7 +86,7 @@ def fix_deadletters(servicebus_client): print("Resending fixed messages") sender.send_messages(msgs_to_send) with receiver: - received_msgs = receiver.receive_messages(max_message_count=10) + received_msgs = receiver.receive_messages(max_message_count=10, max_wait_time=5) for msg in received_msgs: if msg.subject and msg.subject == "Good": print("Received fixed message: Body={}, Subject={}".format(next(msg.body), msg.subject))