diff --git a/sdk/servicebus/azure-servicebus/CHANGELOG.md b/sdk/servicebus/azure-servicebus/CHANGELOG.md index 99dbb05d2860..1c0eff10ecc0 100644 --- a/sdk/servicebus/azure-servicebus/CHANGELOG.md +++ b/sdk/servicebus/azure-servicebus/CHANGELOG.md @@ -7,6 +7,10 @@ * Fixed bug where sync AutoLockRenew does not shutdown itself timely. * Fixed bug where async AutoLockRenew does not support context manager. +**Breaking Changes** + +* Renamed `receive()`, `peek()` `schedule()` and `send()` to `receive_messages()`, `peek_messages()`, `schedule_messages()` and `send_messages()` to align with other service bus SDKs. + ## 7.0.0b3 (2020-06-08) **New Features** diff --git a/sdk/servicebus/azure-servicebus/README.md b/sdk/servicebus/azure-servicebus/README.md index 9ab1645f83c7..b2cbb9b3f898 100644 --- a/sdk/servicebus/azure-servicebus/README.md +++ b/sdk/servicebus/azure-servicebus/README.md @@ -146,19 +146,19 @@ with ServiceBusClient.from_connection_string(connstr) as client: with client.get_queue_sender(queue_name) as sender: # Sending a single message single_message = Message("Single message") - sender.send(single_message) + sender.send_messages(single_message) # Sending a list of messages messages = [Message("First message"), Message("Second message")] - sender.send(messages) + sender.send_messages(messages) ``` -> **NOTE:** A message may be scheduled for delayed delivery using the `ServiceBusSender.schedule()` method, or by specifying `Message.scheduled_enqueue_time_utc` before calling `ServiceBusSender.send()` +> **NOTE:** A message may be scheduled for delayed delivery using the `ServiceBusSender.schedule_messages()` method, or by specifying `Message.scheduled_enqueue_time_utc` before calling `ServiceBusSender.send_messages()` > For more detail on scheduling and schedule cancellation please see a sample [here](./samples/sync_samples/schedule_messages_and_cancellation.py). ### Receive messages from a queue -To receive from a queue, you can either perform an ad-hoc receive via "receiver.receive()" or receive persistently through the receiver itself. +To receive from a queue, you can either perform an ad-hoc receive via "receiver.receive_messages()" or receive persistently through the receiver itself. #### Receive messages from a queue through iterating over ServiceBusReceiver @@ -183,9 +183,9 @@ with ServiceBusClient.from_connection_string(connstr) as client: > See [AutoLockRenewer](#autolockrenew) for a helper to perform this in the background automatically. > Lock duration is set in Azure on the queue or topic itself. -#### [Receive messages from a queue through `ServiceBusReceiver.receive()`][receive_reference] +#### [Receive messages from a queue through `ServiceBusReceiver.receive_messages()`][receive_reference] -> **NOTE:** `ServiceBusReceiver.receive()` receives a single or constrained list of messages through an ad-hoc method call, as opposed to receiving perpetually from the generator. It always returns a list. +> **NOTE:** `ServiceBusReceiver.receive_messages()` receives a single or constrained list of messages through an ad-hoc method call, as opposed to receiving perpetually from the generator. It always returns a list. ```Python from azure.servicebus import ServiceBusClient @@ -196,19 +196,19 @@ queue_name = os.environ['SERVICE_BUS_QUEUE_NAME'] with ServiceBusClient.from_connection_string(connstr) as client: with client.get_queue_receiver(queue_name) as receiver: - received_message_array = receiver.receive(max_wait_time=10) # try to receive a single message within 10 seconds + received_message_array = receiver.receive_messages(max_wait_time=10) # try to receive a single message within 10 seconds if received_message_array: print(str(received_message_array[0])) with client.get_queue_receiver(queue_name, prefetch=5) as receiver: - received_message_array = receiver.receive(max_batch_size=5, max_wait_time=10) # try to receive maximum 5 messages in a batch within 10 seconds + received_message_array = receiver.receive_messages(max_batch_size=5, max_wait_time=10) # try to receive maximum 5 messages in a batch within 10 seconds for message in received_message_array: print(str(message)) ``` In this example, max_batch_size (and prefetch, as required by max_batch_size) declares the maximum number of messages to attempt receiving before hitting a max_wait_time as specified in seconds. -> **NOTE:** It should also be noted that `ServiceBusReceiver.peek()` is subtly different than receiving, as it does not lock the messages being peeked, and thus they cannot be settled. +> **NOTE:** It should also be noted that `ServiceBusReceiver.peek_messages()` is subtly different than receiving, as it does not lock the messages being peeked, and thus they cannot be settled. ### [Sending][session_send_reference] and [receiving][session_receive_reference] a message from a session enabled queue @@ -225,7 +225,7 @@ session_id = os.environ['SERVICE_BUS_SESSION_ID'] with ServiceBusClient.from_connection_string(connstr) as client: with client.get_queue_sender(queue_name) as sender: - sender.send(Message("Session Enabled Message", session_id=session_id)) + sender.send_messages(Message("Session Enabled Message", session_id=session_id)) # If session_id is null here, will receive from the first available session. with client.get_queue_session_receiver(queue_name, session_id) as receiver: @@ -252,7 +252,7 @@ subscription_name = os.environ['SERVICE_BUS_SUBSCRIPTION_NAME'] with ServiceBusClient.from_connection_string(connstr) as client: with client.get_topic_sender(topic_name) as sender: - sender.send(Message("Data")) + sender.send_messages(Message("Data")) # If session_id is null here, will receive from the first available session. with client.get_subscription_receiver(topic_name, subscription_name) as receiver: @@ -386,7 +386,7 @@ renewer = AutoLockRenew() with ServiceBusClient.from_connection_string(connstr) as client: with client.get_queue_session_receiver(queue_name, session_id=session_id) as receiver: renewer.register(receiver.session, timeout=300) # Timeout for how long to maintain the lock for, in seconds. - for msg in receiver.receive(): + for msg in receiver.receive_messages(): renewer.register(msg, timeout=60) # Do your application logic here msg.complete() diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/_servicebus_receiver.py b/sdk/servicebus/azure-servicebus/azure/servicebus/_servicebus_receiver.py index 8c591e3bb879..b2d910f41645 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/_servicebus_receiver.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/_servicebus_receiver.py @@ -284,7 +284,7 @@ def from_connection_string( raise ValueError("Subscription name is missing for the topic. Please specify subscription_name.") return cls(**constructor_args) - def receive(self, max_batch_size=None, max_wait_time=None): + def receive_messages(self, max_batch_size=None, max_wait_time=None): # type: (int, float) -> List[ReceivedMessage] """Receive a batch of messages at once. @@ -372,7 +372,7 @@ def receive_deferred_messages(self, sequence_numbers): m._receiver = self # pylint: disable=protected-access return messages - def peek(self, message_count=1, sequence_number=None): + def peek_messages(self, message_count=1, sequence_number=None): # type: (int, Optional[int]) -> List[PeekMessage] """Browse messages currently pending in the queue. diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/_servicebus_sender.py b/sdk/servicebus/azure-servicebus/azure/servicebus/_servicebus_sender.py index 39ea04d16434..96d5442d741b 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/_servicebus_sender.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/_servicebus_sender.py @@ -190,7 +190,7 @@ def _send(self, message, timeout=None, last_exception=None): self._set_msg_timeout(timeout, last_exception) self._handler.send_message(message.message) - def schedule(self, messages, schedule_time_utc): + def schedule_messages(self, messages, schedule_time_utc): # type: (Union[Message, List[Message]], datetime.datetime) -> List[int] """Send Message or multiple Messages to be enqueued at a specific time. Returns a list of the sequence numbers of the enqueued messages. @@ -295,7 +295,7 @@ def from_connection_string( ) return cls(**constructor_args) - def send(self, message): + def send_messages(self, message): # type: (Union[Message, BatchMessage, List[Message]]) -> None """Sends message and blocks until acknowledgement is received or operation times out. diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/aio/_servicebus_receiver_async.py b/sdk/servicebus/azure-servicebus/azure/servicebus/aio/_servicebus_receiver_async.py index bd1266dc5a90..7619159a8faf 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/aio/_servicebus_receiver_async.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/aio/_servicebus_receiver_async.py @@ -272,7 +272,7 @@ def from_connection_string( raise ValueError("Subscription name is missing for the topic. Please specify subscription_name.") return cls(**constructor_args) - async def receive(self, max_batch_size=None, max_wait_time=None): + async def receive_messages(self, max_batch_size=None, max_wait_time=None): # type: (int, float) -> List[ReceivedMessage] """Receive a batch of messages at once. @@ -360,7 +360,7 @@ async def receive_deferred_messages(self, sequence_numbers): m._receiver = self # pylint: disable=protected-access return messages - async def peek(self, message_count=1, sequence_number=0): + async def peek_messages(self, message_count=1, sequence_number=0): """Browse messages currently pending in the queue. Peeked messages are not removed from queue, nor are they locked. They cannot be completed, diff --git a/sdk/servicebus/azure-servicebus/azure/servicebus/aio/_servicebus_sender_async.py b/sdk/servicebus/azure-servicebus/azure/servicebus/aio/_servicebus_sender_async.py index 1cb20977934e..c59bc36a5037 100644 --- a/sdk/servicebus/azure-servicebus/azure/servicebus/aio/_servicebus_sender_async.py +++ b/sdk/servicebus/azure-servicebus/azure/servicebus/aio/_servicebus_sender_async.py @@ -134,7 +134,7 @@ async def _send(self, message, timeout=None, last_exception=None): self._set_msg_timeout(timeout, last_exception) await self._handler.send_message_async(message.message) - async def schedule(self, messages, schedule_time_utc): + async def schedule_messages(self, messages, schedule_time_utc): # type: (Union[Message, List[Message]], datetime.datetime) -> List[int] """Send Message or multiple Messages to be enqueued at a specific time by the service. Returns a list of the sequence numbers of the enqueued messages. @@ -236,7 +236,7 @@ def from_connection_string( ) return cls(**constructor_args) - async def send(self, message): + async def send_messages(self, message): # type: (Union[Message, BatchMessage, List[Message]]) -> None """Sends message and blocks until acknowledgement is received or operation times out. diff --git a/sdk/servicebus/azure-servicebus/migration_guide.md b/sdk/servicebus/azure-servicebus/migration_guide.md index 1715af743099..ab810442caf7 100644 --- a/sdk/servicebus/azure-servicebus/migration_guide.md +++ b/sdk/servicebus/azure-servicebus/migration_guide.md @@ -25,8 +25,8 @@ As a user this will be largely transparent to you, as initialization will still the primary difference will be that rather than creating a queue_client, for instance, and then a sender off of that, you would simply create a servicebus queue sender off of your ServiceBusClient instance via the "get_queue_sender" method. -It should also be noted that many of the helper methods that previously existed on the intermediary client (e.g. QueueClient and Peek) now -exist on the receiver (in the case of peek) or sender itself. This is to better consolidate functionality and align messaging link lifetime +It should also be noted that many of the helper methods that previously existed on the intermediary client (e.g. QueueClient and `peek()`) now +exist on the receiver (in the case of `peek()`) or sender itself. This is to better consolidate functionality and align messaging link lifetime semantics with the sender or receiver lifetime. ### Client constructors @@ -40,27 +40,28 @@ semantics with the sender or receiver lifetime. | In v0.50 | Equivalent in v7 | Sample | |---|---|---| -| `QueueClient.from_connection_string().get_receiver().fetch_next() and ServiceBusClient.from_connection_string().get_queue().get_receiver().fetch_next()`| `ServiceBusClient.from_connection_string().get_queue_receiver().receive()`| [Get a receiver and receive a single batch of messages](./samples/sync_samples/receive_queue.py) | +| `QueueClient.from_connection_string().get_receiver().fetch_next() and ServiceBusClient.from_connection_string().get_queue().get_receiver().fetch_next()`| `ServiceBusClient.from_connection_string().get_queue_receiver().receive_messages()`| [Get a receiver and receive a single batch of messages](./samples/sync_samples/receive_queue.py) | +| `QueueClient.from_connection_string().get_receiver().peek() and ServiceBusClient.from_connection_string().get_queue().get_receiver().peek()`| `ServiceBusClient.from_connection_string().get_queue_receiver().peek_messages()`| [Get a receiver and receive a single batch of messages](./samples/sync_samples/receive_queue.py) | ### Sending messages | In v0.50 | Equivalent in v7 | Sample | |---|---|---| -| `QueueClient.from_connection_string().send() and ServiceBusClient.from_connection_string().get_queue().get_sender().send()`| `ServiceBusClient.from_connection_string().get_queue_sender().send()`| [Get a sender and send a message](./samples/sync_samples/send_queue.py) | -| `queue_client.send(BatchMessage(["data 1", "data 2", ...]))`| `batch = queue_sender.create_batch() batch.add(Message("data 1")) queue_sender.send(batch)`| [Create and send a batch of messages](./samples/sync_samples/send_queue.py) | +| `QueueClient.from_connection_string().send() and ServiceBusClient.from_connection_string().get_queue().get_sender().send()`| `ServiceBusClient.from_connection_string().get_queue_sender().send_messages()`| [Get a sender and send a message](./samples/sync_samples/send_queue.py) | +| `queue_client.send(BatchMessage(["data 1", "data 2", ...]))`| `batch = queue_sender.create_batch() batch.add(Message("data 1")) queue_sender.send_messages(batch)`| [Create and send a batch of messages](./samples/sync_samples/send_queue.py) | ### Scheduling messages and cancelling scheduled messages | In v0.50 | Equivalent in v7 | Sample | |---|---|---| -| `queue_client.get_sender().schedule(schedule_time_utc, message1, message2)` | `sb_client.get_queue_sender().schedule([message1, message2], schedule_time_utc)` | [Schedule messages](./samples/sync_samples/schedule_messages_and_cancellation.py) | +| `queue_client.get_sender().schedule(schedule_time_utc, message1, message2)` | `sb_client.get_queue_sender().schedule_messages([message1, message2], schedule_time_utc)` | [Schedule messages](./samples/sync_samples/schedule_messages_and_cancellation.py) | | `queue_client.get_sender().cancel_scheduled_messages(sequence_number1, sequence_number2)`| `sb_client.get_queue_sender().cancel_scheduled_messages([sequence_number1, sequence_number2])` | [Cancel scheduled messages](./samples/sync_samples/schedule_messages_and_cancellation.py)| ### Working with sessions | In v0.50 | Equivalent in v7 | Sample | |---|---|---| -| `queue_client.send(message, session='foo') and queue_client.get_sender(session='foo').send(message)`| `sb_client.get_queue_sender().send(Message('body', session_id='foo'))`| [Send a message to a session](./samples/sync_samples/session_send_receive.py) | +| `queue_client.send(message, session='foo') and queue_client.get_sender(session='foo').send(message)`| `sb_client.get_queue_sender().send_messages(Message('body', session_id='foo'))`| [Send a message to a session](./samples/sync_samples/session_send_receive.py) | | `AutoLockRenew().register(queue_client.get_receiver(session='foo'))`| `AutoLockRenew().register(sb_client.get_queue_session_receiver(session_id='foo').session)`| [Access a session and ensure its lock is auto-renewed](./samples/sync_samples/session_send_receive.py) | | `receiver.get_session_state()` | `receiver.session.get_session_state()` | [Perform session specific operations on a receiver](./samples/sync_samples/session_send_receive.py) @@ -118,7 +119,7 @@ Becomes this in v7: with ServiceBusClient.from_connection_string(conn_str=CONNECTION_STR) as client: with client.get_queue_receiver(queue_name=QUEUE_NAME) as receiver: - batch = receiver.receive(max_batch_size=10, max_wait_time=5) + batch = receiver.receive_messages(max_batch_size=10, max_wait_time=5) for message in batch: print("Message: {}".format(message)) message.complete() @@ -148,12 +149,12 @@ with queue_client.get_sender() as sender: # Send one at a time. for i in range(100): message = Message("Sample message no. {}".format(i)) - sender.send(message) + sender.schedule_messages(message) # Send as a batch. messages_to_batch = [Message("Batch message no. {}".format(i)) for i in range(10)] batch = BatchMessage(messages_to_batch) - sender.send(batch) + sender.schedule_messages(batch) ``` In v7: @@ -164,11 +165,11 @@ with ServiceBusClient.from_connection_string(conn_str=CONNECTION_STR) as client: # Sending one at a time. for i in range(100): message = Message("Sample message no. {}".format(i)) - sender.send(message) + sender.schedule_messages(message) # Send as a batch batch = new BatchMessage() for i in range(10): batch.add(Message("Batch message no. {}".format(i))) - sender.send(batch) + sender.schedule_messages(batch) ``` diff --git a/sdk/servicebus/azure-servicebus/samples/async_samples/proxy_async.py b/sdk/servicebus/azure-servicebus/samples/async_samples/proxy_async.py index cd4931c69513..8c7c10a1b19b 100644 --- a/sdk/servicebus/azure-servicebus/samples/async_samples/proxy_async.py +++ b/sdk/servicebus/azure-servicebus/samples/async_samples/proxy_async.py @@ -30,7 +30,7 @@ async def send_single_message(sender): message = Message("DATA" * 64) - await sender.send(message) + await sender.send_messages(message) async def main(): 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 48e51706dab1..d4742211a51a 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 @@ -25,7 +25,7 @@ async def main(): async with servicebus_client: receiver = servicebus_client.get_queue_deadletter_receiver(queue_name=QUEUE_NAME, prefetch=10) async with receiver: - received_msgs = await receiver.receive(max_batch_size=10, max_wait_time=5) + received_msgs = await receiver.receive_messages(max_batch_size=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 f945cb0ae919..c0cf7edd7fbc 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 @@ -26,7 +26,7 @@ async def main(): receiver = servicebus_client.get_queue_receiver(queue_name=QUEUE_NAME, prefetch=10) async with receiver: - received_msgs = await receiver.receive(max_batch_size=10, max_wait_time=5) + received_msgs = await receiver.receive_messages(max_batch_size=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_peek_async.py b/sdk/servicebus/azure-servicebus/samples/async_samples/receive_peek_async.py index 675c12512077..00e16edae3fb 100644 --- a/sdk/servicebus/azure-servicebus/samples/async_samples/receive_peek_async.py +++ b/sdk/servicebus/azure-servicebus/samples/async_samples/receive_peek_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.peek(message_count=2) + received_msgs = await receiver.peek_messages(message_count=2) for msg in received_msgs: print(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 1cdee11336f4..37573c79abd6 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, prefetch=10) async with receiver: - received_msgs = await receiver.receive(max_batch_size=10, max_wait_time=5) + received_msgs = await receiver.receive_messages(max_batch_size=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 36716aaf8f3c..f6f8c881be5f 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 @@ -30,7 +30,7 @@ async def main(): prefetch=10 ) async with receiver: - received_msgs = await receiver.receive(max_batch_size=10, max_wait_time=5) + received_msgs = await receiver.receive_messages(max_batch_size=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/sample_code_servicebus_async.py b/sdk/servicebus/azure-servicebus/samples/async_samples/sample_code_servicebus_async.py index b978ce56d24a..b4ded73c2eba 100644 --- a/sdk/servicebus/azure-servicebus/samples/async_samples/sample_code_servicebus_async.py +++ b/sdk/servicebus/azure-servicebus/samples/async_samples/sample_code_servicebus_async.py @@ -193,7 +193,7 @@ async def example_send_and_receive_async(): # [START send_async] async with servicebus_sender: message = Message("Hello World") - await servicebus_sender.send(message) + await servicebus_sender.send_messages(message) # [END send_async] # [START create_batch_async] @@ -204,14 +204,14 @@ async def example_send_and_receive_async(): # [START peek_messages_async] async with servicebus_receiver: - messages = await servicebus_receiver.peek() + messages = await servicebus_receiver.peek_messages() for message in messages: print(message) # [END peek_messages_async] # [START receive_async] async with servicebus_receiver: - messages = await servicebus_receiver.receive(max_wait_time=5) + messages = await servicebus_receiver.receive_messages(max_wait_time=5) for message in messages: print(message) await message.complete() @@ -233,11 +233,11 @@ async def example_receive_deferred_async(): servicebus_sender = await example_create_servicebus_sender_async() servicebus_receiver = await example_create_servicebus_receiver_async() async with servicebus_sender: - await servicebus_sender.send(Message("Hello World")) + await servicebus_sender.send_messages(Message("Hello World")) # [START receive_defer_async] async with servicebus_receiver: deferred_sequenced_numbers = [] - messages = await servicebus_receiver.receive(max_wait_time=5) + messages = await servicebus_receiver.receive_messages(max_wait_time=5) for message in messages: deferred_sequenced_numbers.append(message.sequence_number) print(message) @@ -302,7 +302,7 @@ async def example_schedule_ops_async(): async with servicebus_sender: scheduled_time_utc = datetime.datetime.utcnow() + datetime.timedelta(seconds=30) scheduled_messages = [Message("Scheduled message") for _ in range(10)] - sequence_nums = await servicebus_sender.schedule(scheduled_messages, scheduled_time_utc) + sequence_nums = await servicebus_sender.schedule_messages(scheduled_messages, scheduled_time_utc) # [END scheduling_messages_async] # [START cancel_scheduled_messages_async] diff --git a/sdk/servicebus/azure-servicebus/samples/async_samples/schedule_messages_and_cancellation_async.py b/sdk/servicebus/azure-servicebus/samples/async_samples/schedule_messages_and_cancellation_async.py index 05458e1169dc..776cc3e78355 100644 --- a/sdk/servicebus/azure-servicebus/samples/async_samples/schedule_messages_and_cancellation_async.py +++ b/sdk/servicebus/azure-servicebus/samples/async_samples/schedule_messages_and_cancellation_async.py @@ -24,7 +24,7 @@ async def schedule_single_message(sender): message = Message("Message to be scheduled") scheduled_time_utc = datetime.datetime.utcnow() + datetime.timedelta(seconds=30) - sequence_number = await sender.schedule(message, scheduled_time_utc) + sequence_number = await sender.schedule_messages(message, scheduled_time_utc) return sequence_number @@ -34,7 +34,7 @@ async def schedule_multiple_messages(sender): messages_to_schedule.append(Message("Message to be scheduled")) scheduled_time_utc = datetime.datetime.utcnow() + datetime.timedelta(seconds=30) - sequence_numbers = await sender.schedule(messages_to_schedule, scheduled_time_utc) + sequence_numbers = await sender.schedule_messages(messages_to_schedule, scheduled_time_utc) return sequence_numbers diff --git a/sdk/servicebus/azure-servicebus/samples/async_samples/send_queue_async.py b/sdk/servicebus/azure-servicebus/samples/async_samples/send_queue_async.py index 0dfeaecc86e1..06a7d8ab1ad0 100644 --- a/sdk/servicebus/azure-servicebus/samples/async_samples/send_queue_async.py +++ b/sdk/servicebus/azure-servicebus/samples/async_samples/send_queue_async.py @@ -22,7 +22,7 @@ async def send_single_message(sender): message = Message("DATA" * 64) - await sender.send(message) + await sender.send_messages(message) async def send_batch_message(sender): @@ -34,7 +34,7 @@ async def send_batch_message(sender): # BatchMessage object reaches max_size. # New BatchMessage object can be created here to send more data. break - await sender.send(batch_message) + await sender.send_messages(batch_message) async def main(): diff --git a/sdk/servicebus/azure-servicebus/samples/async_samples/send_topic_async.py b/sdk/servicebus/azure-servicebus/samples/async_samples/send_topic_async.py index 6b210a540eee..c38efc7ed58a 100644 --- a/sdk/servicebus/azure-servicebus/samples/async_samples/send_topic_async.py +++ b/sdk/servicebus/azure-servicebus/samples/async_samples/send_topic_async.py @@ -22,7 +22,7 @@ async def send_single_message(sender): message = Message("DATA" * 64) - await sender.send(message) + await sender.send_messages(message) async def send_batch_message(sender): @@ -34,7 +34,7 @@ async def send_batch_message(sender): # BatchMessage object reaches max_size. # New BatchMessage object can be created here to send more data. break - await sender.send(batch_message) + await sender.send_messages(batch_message) async def main(): diff --git a/sdk/servicebus/azure-servicebus/samples/async_samples/session_pool_receive_async.py b/sdk/servicebus/azure-servicebus/samples/async_samples/session_pool_receive_async.py index c0481149a1eb..9b6de7dadb8f 100644 --- a/sdk/servicebus/azure-servicebus/samples/async_samples/session_pool_receive_async.py +++ b/sdk/servicebus/azure-servicebus/samples/async_samples/session_pool_receive_async.py @@ -53,8 +53,8 @@ async def sample_session_send_receive_with_pool_async(connection_string, queue_n for session_id in sessions: async with client.get_queue_sender(queue_name) as sender: - await asyncio.gather(*[sender.send(Message("Sample message no. {}".format(i), session_id=session_id)) for i in range(20)]) - await sender.send(Message("shutdown", session_id=session_id)) + await asyncio.gather(*[sender.send_messages(Message("Sample message no. {}".format(i), session_id=session_id)) for i in range(20)]) + await sender.send_messages(Message("shutdown", session_id=session_id)) receive_sessions = [message_processing(client, queue_name) for _ in range(concurrent_receivers)] await asyncio.gather(*receive_sessions) 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 b72de8d345be..6f023b427c7a 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 @@ -24,7 +24,7 @@ async def send_single_message(sender): message = Message("DATA" * 64) message.session_id = SESSION_ID - await sender.send(message) + await sender.send_messages(message) async def send_batch_message(sender): @@ -38,14 +38,14 @@ async def send_batch_message(sender): # BatchMessage object reaches max_size. # New BatchMessage object can be created here to send more data. break - await sender.send(batch_message) + await sender.send_messages(batch_message) async def receive_batch_messages(receiver): session = receiver.session await session.set_session_state("START") print("Session state:", await session.get_session_state()) - received_msgs = await receiver.receive(max_batch_size=10, max_wait_time=5) + received_msgs = await receiver.receive_messages(max_batch_size=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/proxy.py b/sdk/servicebus/azure-servicebus/samples/sync_samples/proxy.py index f51c0c09a1e6..4d25506c7289 100644 --- a/sdk/servicebus/azure-servicebus/samples/sync_samples/proxy.py +++ b/sdk/servicebus/azure-servicebus/samples/sync_samples/proxy.py @@ -28,7 +28,7 @@ def send_single_message(sender): message = Message("DATA" * 64) - sender.send(message) + sender.send_messages(message) servicebus_client = ServiceBusClient.from_connection_string( 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 239d8b233d69..67c12e3a9540 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 @@ -22,7 +22,7 @@ with servicebus_client: receiver = servicebus_client.get_queue_deadletter_receiver(queue_name=QUEUE_NAME, prefetch=10) with receiver: - received_msgs = receiver.receive(max_batch_size=10, max_wait_time=5) + received_msgs = receiver.receive_messages(max_batch_size=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 9fd2aae15eec..1ca4417cbea0 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 @@ -22,7 +22,7 @@ with servicebus_client: receiver = servicebus_client.get_queue_receiver(queue_name=QUEUE_NAME, prefetch=10) with receiver: - received_msgs = receiver.receive(max_batch_size=10, max_wait_time=5) + received_msgs = receiver.receive_messages(max_batch_size=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_peek.py b/sdk/servicebus/azure-servicebus/samples/sync_samples/receive_peek.py index 301db5ab28ba..1fc513fcb8e9 100644 --- a/sdk/servicebus/azure-servicebus/samples/sync_samples/receive_peek.py +++ b/sdk/servicebus/azure-servicebus/samples/sync_samples/receive_peek.py @@ -22,7 +22,7 @@ with servicebus_client: receiver = servicebus_client.get_queue_receiver(queue_name=QUEUE_NAME) with receiver: - received_msgs = receiver.peek(message_count=2) + received_msgs = receiver.peek_messages(message_count=2) for msg in received_msgs: print(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 580d725dbc1f..7032c45cc261 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, prefetch=10) with receiver: - received_msgs = receiver.receive(max_batch_size=10, max_wait_time=5) + received_msgs = receiver.receive_messages(max_batch_size=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 bc00a398c52f..fa20b01f6888 100644 --- a/sdk/servicebus/azure-servicebus/samples/sync_samples/receive_subscription.py +++ b/sdk/servicebus/azure-servicebus/samples/sync_samples/receive_subscription.py @@ -27,7 +27,7 @@ prefetch=10 ) with receiver: - received_msgs = receiver.receive(max_batch_size=10, max_wait_time=5) + received_msgs = receiver.receive_messages(max_batch_size=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/sample_code_servicebus.py b/sdk/servicebus/azure-servicebus/samples/sync_samples/sample_code_servicebus.py index 9f0efa97234b..604149e5c2b6 100644 --- a/sdk/servicebus/azure-servicebus/samples/sync_samples/sample_code_servicebus.py +++ b/sdk/servicebus/azure-servicebus/samples/sync_samples/sample_code_servicebus.py @@ -189,7 +189,7 @@ def example_send_and_receive_sync(): # [START send_sync] with servicebus_sender: message = Message("Hello World") - servicebus_sender.send(message) + servicebus_sender.send_messages(message) # [END send_sync] # [START create_batch_sync] @@ -208,7 +208,7 @@ def example_send_and_receive_sync(): # [START peek_messages_sync] with servicebus_receiver: - messages = servicebus_receiver.peek() + messages = servicebus_receiver.peek_messages() for message in messages: print(message) # [END peek_messages_sync] @@ -227,14 +227,14 @@ def example_send_and_receive_sync(): # [START receive_sync] with servicebus_receiver: - messages = servicebus_receiver.receive(max_wait_time=5) + messages = servicebus_receiver.receive_messages(max_wait_time=5) for message in messages: print(message) message.complete() # [END receive_sync] # [START receive_complex_message] - messages = servicebus_receiver.receive(max_wait_time=5) + messages = servicebus_receiver.receive_messages(max_wait_time=5) for message in messages: print("Receiving: {}".format(message)) print("Time to live: {}".format(message.time_to_live)) @@ -261,11 +261,11 @@ def example_receive_deferred_sync(): servicebus_sender = example_create_servicebus_sender_sync() servicebus_receiver = example_create_servicebus_receiver_sync() with servicebus_sender: - servicebus_sender.send(Message("Hello World")) + servicebus_sender.send_messages(Message("Hello World")) # [START receive_defer_sync] with servicebus_receiver: deferred_sequenced_numbers = [] - messages = servicebus_receiver.receive(max_wait_time=5) + messages = servicebus_receiver.receive_messages(max_wait_time=5) for message in messages: deferred_sequenced_numbers.append(message.sequence_number) print(message) @@ -350,7 +350,7 @@ def example_schedule_ops_sync(): with servicebus_sender: scheduled_time_utc = datetime.datetime.utcnow() + datetime.timedelta(seconds=30) scheduled_messages = [Message("Scheduled message") for _ in range(10)] - sequence_nums = servicebus_sender.schedule(scheduled_messages, scheduled_time_utc) + sequence_nums = servicebus_sender.schedule_messages(scheduled_messages, scheduled_time_utc) # [END scheduling_messages] # [START cancel_scheduled_messages] diff --git a/sdk/servicebus/azure-servicebus/samples/sync_samples/schedule_messages_and_cancellation.py b/sdk/servicebus/azure-servicebus/samples/sync_samples/schedule_messages_and_cancellation.py index 8d43f3c42deb..96888291ac52 100644 --- a/sdk/servicebus/azure-servicebus/samples/sync_samples/schedule_messages_and_cancellation.py +++ b/sdk/servicebus/azure-servicebus/samples/sync_samples/schedule_messages_and_cancellation.py @@ -22,7 +22,7 @@ def schedule_single_message(sender): message = Message("Message to be scheduled") scheduled_time_utc = datetime.datetime.utcnow() + datetime.timedelta(seconds=30) - sequence_number = sender.schedule(message, scheduled_time_utc) + sequence_number = sender.schedule_messages(message, scheduled_time_utc) return sequence_number @@ -32,7 +32,7 @@ def schedule_multiple_messages(sender): messages_to_schedule.append(Message("Message to be scheduled")) scheduled_time_utc = datetime.datetime.utcnow() + datetime.timedelta(seconds=30) - sequence_numbers = sender.schedule(messages_to_schedule, scheduled_time_utc) + sequence_numbers = sender.schedule_messages(messages_to_schedule, scheduled_time_utc) return sequence_numbers diff --git a/sdk/servicebus/azure-servicebus/samples/sync_samples/send_queue.py b/sdk/servicebus/azure-servicebus/samples/sync_samples/send_queue.py index b553b9212d89..b111937cd50c 100644 --- a/sdk/servicebus/azure-servicebus/samples/sync_samples/send_queue.py +++ b/sdk/servicebus/azure-servicebus/samples/sync_samples/send_queue.py @@ -20,7 +20,7 @@ def send_single_message(sender): message = Message("DATA" * 64) - sender.send(message) + sender.send_messages(message) def send_batch_message(sender): @@ -32,7 +32,7 @@ def send_batch_message(sender): # BatchMessage object reaches max_size. # New BatchMessage object can be created here to send more data. break - sender.send(batch_message) + sender.send_messages(batch_message) servicebus_client = ServiceBusClient.from_connection_string(conn_str=CONNECTION_STR, logging_enable=True) diff --git a/sdk/servicebus/azure-servicebus/samples/sync_samples/send_topic.py b/sdk/servicebus/azure-servicebus/samples/sync_samples/send_topic.py index 37bca424a1cd..5ce2deb226d6 100644 --- a/sdk/servicebus/azure-servicebus/samples/sync_samples/send_topic.py +++ b/sdk/servicebus/azure-servicebus/samples/sync_samples/send_topic.py @@ -20,7 +20,7 @@ def send_single_message(sender): message = Message("DATA" * 64) - sender.send(message) + sender.send_messages(message) def send_batch_message(sender): @@ -32,7 +32,7 @@ def send_batch_message(sender): # BatchMessage object reaches max_size. # New BatchMessage object can be created here to send more data. break - sender.send(batch_message) + sender.send_messages(batch_message) servicebus_client = ServiceBusClient.from_connection_string(conn_str=CONNECTION_STR, logging_enable=True) diff --git a/sdk/servicebus/azure-servicebus/samples/sync_samples/session_pool_receive.py b/sdk/servicebus/azure-servicebus/samples/sync_samples/session_pool_receive.py index a95d1aaac0bf..949af4e42e46 100644 --- a/sdk/servicebus/azure-servicebus/samples/sync_samples/session_pool_receive.py +++ b/sdk/servicebus/azure-servicebus/samples/sync_samples/session_pool_receive.py @@ -53,7 +53,7 @@ def sample_session_send_receive_with_pool(connection_string, queue_name): for session_id in sessions: for i in range(20): message = Message("Sample message no. {}".format(i), session_id=session_id) - sender.send(message) + sender.send_messages(message) all_messages = [] futures = [] 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 5a4eb9086ac5..d24eeccc572f 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 @@ -21,7 +21,7 @@ def send_single_message(sender): message = Message("DATA" * 64, session_id=SESSION_ID) - sender.send(message) + sender.send_messages(message) def send_batch_message(sender): @@ -34,14 +34,14 @@ def send_batch_message(sender): # BatchMessage object reaches max_size. # New BatchMessage object can be created here to send more data. break - sender.send(batch_message) + sender.send_messages(batch_message) def receive_batch_message(receiver): session = receiver.session session.set_session_state("START") print("Session state:", session.get_session_state()) - received_msgs = receiver.receive(max_batch_size=10, max_wait_time=5) + received_msgs = receiver.receive_messages(max_batch_size=10, max_wait_time=5) for msg in received_msgs: print(str(msg)) msg.complete() diff --git a/sdk/servicebus/azure-servicebus/tests/async_tests/test_queues_async.py b/sdk/servicebus/azure-servicebus/tests/async_tests/test_queues_async.py index 90e27a482d7b..2aabeaa741c7 100644 --- a/sdk/servicebus/azure-servicebus/tests/async_tests/test_queues_async.py +++ b/sdk/servicebus/azure-servicebus/tests/async_tests/test_queues_async.py @@ -52,7 +52,7 @@ async def test_async_queue_by_queue_client_conn_str_receive_handler_peeklock(sel for i in range(10): message = Message("Handler message no. {}".format(i)) message.enqueue_sequence_number = i - await sender.send(message) + await sender.send_messages(message) with pytest.raises(ServiceBusConnectionError): await (sb_client.get_queue_session_receiver(servicebus_queue.name, session_id="test", idle_timeout=5))._open_with_retry() @@ -80,7 +80,7 @@ async def test_async_queue_by_queue_client_send_multiple_messages(self, serviceb for i in range(10): message = Message("Handler message no. {}".format(i)) messages.append(message) - await sender.send(messages) + await sender.send_messages(messages) async with sb_client.get_queue_receiver(servicebus_queue.name, idle_timeout=5) as receiver: count = 0 @@ -103,9 +103,9 @@ async def test_github_issue_7079_async(self, servicebus_namespace_connection_str async with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(5): - await sender.send(Message("Message {}".format(i))) + await sender.send_messages(Message("Message {}".format(i))) async with sb_client.get_queue_receiver(servicebus_queue.name, mode=ReceiveSettleMode.ReceiveAndDelete, idle_timeout=5) as messages: - batch = await messages.receive() + batch = await messages.receive_messages() count = len(batch) async for message in messages: _logger.debug(message) @@ -123,7 +123,7 @@ async def test_github_issue_6178_async(self, servicebus_namespace_connection_str async with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(3): - await sender.send(Message("Message {}".format(i))) + await sender.send_messages(Message("Message {}".format(i))) async with sb_client.get_queue_receiver(servicebus_queue.name, idle_timeout=60) as messages: async for message in messages: _logger.debug(message) @@ -147,7 +147,7 @@ async def test_async_queue_by_queue_client_conn_str_receive_handler_receiveandde for i in range(10): message = Message("Handler message no. {}".format(i)) message.enqueue_sequence_number = i - await sender.send(message) + await sender.send_messages(message) messages = [] async with sb_client.get_queue_receiver(servicebus_queue.name, mode=ReceiveSettleMode.ReceiveAndDelete, idle_timeout=5) as receiver: @@ -178,7 +178,7 @@ async def test_async_queue_by_queue_client_conn_str_receive_handler_with_stop(se async with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(10): message = Message("Stop message no. {}".format(i)) - await sender.send(message) + await sender.send_messages(message) messages = [] receiver = sb_client.get_queue_receiver(servicebus_queue.name, idle_timeout=5, prefetch=0) @@ -216,7 +216,7 @@ async def test_async_queue_by_servicebus_client_iter_messages_simple(self, servi async with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(10): message = Message("Iter message no. {}".format(i)) - await sender.send(message) + await sender.send_messages(message) count = 0 async for message in receiver: @@ -247,7 +247,7 @@ async def test_async_queue_by_servicebus_conn_str_client_iter_messages_with_aban async with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(10): message = Message("Abandoned message no. {}".format(i)) - await sender.send(message) + await sender.send_messages(message) count = 0 async for message in receiver: @@ -284,7 +284,7 @@ async def test_async_queue_by_servicebus_client_iter_messages_with_defer(self, s async with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(10): message = Message("Deferred message no. {}".format(i)) - await sender.send(message) + await sender.send_messages(message) count = 0 async for message in receiver: @@ -317,7 +317,7 @@ async def test_async_queue_by_servicebus_client_iter_messages_with_retrieve_defe async with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(10): message = Message("Deferred message no. {}".format(i)) - await sender.send(message) + await sender.send_messages(message) count = 0 async for message in receiver: @@ -349,7 +349,7 @@ async def test_async_queue_by_servicebus_client_iter_messages_with_retrieve_defe deferred_messages = [] async with sb_client.get_queue_sender(servicebus_queue.name) as sender: for message in [Message("Deferred message no. {}".format(i)) for i in range(10)]: - results = await sender.send(message) + results = await sender.send_messages(message) async with sb_client.get_queue_receiver(servicebus_queue.name, idle_timeout=5, mode=ReceiveSettleMode.PeekLock) as receiver: count = 0 @@ -383,7 +383,7 @@ async def test_async_queue_by_servicebus_client_iter_messages_with_retrieve_defe deferred_messages = [] async with sb_client.get_queue_sender(servicebus_queue.name) as sender: for message in [Message("Deferred message no. {}".format(i)) for i in range(10)]: - results = await sender.send(message) + results = await sender.send_messages(message) async with sb_client.get_queue_receiver(servicebus_queue.name, idle_timeout=5, mode=ReceiveSettleMode.PeekLock) as receiver: count = 0 @@ -424,7 +424,7 @@ async def test_async_queue_by_servicebus_client_iter_messages_with_retrieve_defe deferred_messages = [] async with sb_client.get_queue_sender(servicebus_queue.name) as sender: for message in [Message("Deferred message no. {}".format(i)) for i in range(10)]: - results = await sender.send(message) + results = await sender.send_messages(message) count = 0 async with sb_client.get_queue_receiver(servicebus_queue.name, idle_timeout=5) as receiver: @@ -460,7 +460,7 @@ async def test_async_queue_by_servicebus_client_iter_messages_with_retrieve_defe async with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(3): message = Message("Deferred message no. {}".format(i)) - await sender.send(message) + await sender.send_messages(message) count = 0 async for message in receiver: @@ -492,16 +492,16 @@ async def test_async_queue_by_servicebus_client_receive_batch_with_deadletter(se async with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(10): message = Message("Dead lettered message no. {}".format(i)) - await sender.send(message) + await sender.send_messages(message) count = 0 - messages = await receiver.receive() + messages = await receiver.receive_messages() while messages: for message in messages: print_message(_logger, message) count += 1 await message.dead_letter(reason="Testing reason", description="Testing description") - messages = await receiver.receive() + messages = await receiver.receive_messages() assert count == 10 @@ -539,16 +539,16 @@ async def test_async_queue_by_servicebus_client_receive_batch_with_retrieve_dead async with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(10): message = Message("Dead lettered message no. {}".format(i)) - await sender.send(message) + await sender.send_messages(message) count = 0 - messages = await receiver.receive() + messages = await receiver.receive_messages() while messages: for message in messages: print_message(_logger, message) await message.dead_letter(reason="Testing reason", description="Testing description") count += 1 - messages = await receiver.receive() + messages = await receiver.receive_messages() assert count == 10 @@ -579,7 +579,7 @@ async def test_async_queue_by_servicebus_client_session_fail(self, servicebus_na await sb_client.get_queue_session_receiver(servicebus_queue.name, session_id="test")._open_with_retry() async with sb_client.get_queue_sender(servicebus_queue.name) as sender: - await sender.send(Message("test session sender", session_id="test")) + await sender.send_messages(Message("test session sender", session_id="test")) @pytest.mark.liveTest @pytest.mark.live_test_only @@ -593,10 +593,10 @@ async def test_async_queue_by_servicebus_client_browse_messages_client(self, ser async with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(5): message = Message("Test message no. {}".format(i)) - await sender.send(message) + await sender.send_messages(message) async with sb_client.get_queue_receiver(servicebus_queue.name) as receiver: - messages = await receiver.peek(5) + messages = await receiver.peek_messages(5) assert len(messages) == 5 assert all(isinstance(m, PeekMessage) for m in messages) for message in messages: @@ -617,9 +617,9 @@ async def test_async_queue_by_servicebus_client_browse_messages_with_receiver(se async with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(5): message = Message("Test message no. {}".format(i)) - await sender.send(message) + await sender.send_messages(message) - messages = await receiver.peek(5) + messages = await receiver.peek_messages(5) assert len(messages) > 0 assert all(isinstance(m, PeekMessage) for m in messages) for message in messages: @@ -637,7 +637,7 @@ async def test_async_queue_by_servicebus_client_browse_empty_messages(self, serv servicebus_namespace_connection_string, logging_enable=False) as sb_client: async with sb_client.get_queue_receiver(servicebus_queue.name, idle_timeout=5, mode=ReceiveSettleMode.PeekLock, prefetch=10) as receiver: - messages = await receiver.peek(10) + messages = await receiver.peek_messages(10) assert len(messages) == 0 @pytest.mark.liveTest @@ -655,12 +655,12 @@ async def test_async_queue_by_servicebus_client_renew_message_locks(self, servic async with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(locks): message = Message("Test message no. {}".format(i)) - await sender.send(message) + await sender.send_messages(message) - messages.extend(await receiver.receive()) + messages.extend(await receiver.receive_messages()) recv = True while recv: - recv = await receiver.receive() + recv = await receiver.receive_messages() messages.extend(recv) try: @@ -690,7 +690,7 @@ async def test_async_queue_by_queue_client_conn_str_receive_handler_with_autoloc async with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(10): message = Message("{}".format(i)) - await sender.send(message) + await sender.send_messages(message) renewer = AutoLockRenew() messages = [] @@ -740,11 +740,11 @@ async def test_async_queue_by_servicebus_client_fail_send_messages(self, service async with sb_client.get_queue_sender(servicebus_queue.name) as sender: with pytest.raises(MessageContentTooLarge): - await sender.send(Message(too_large)) + await sender.send_messages(Message(too_large)) half_too_large = "A" * int((1024 * 256) / 2) with pytest.raises(MessageContentTooLarge): - await sender.send([Message(half_too_large), Message(half_too_large)]) + await sender.send_messages([Message(half_too_large), Message(half_too_large)]) @pytest.mark.liveTest @pytest.mark.live_test_only @@ -760,11 +760,11 @@ async def test_async_queue_message_time_to_live(self, servicebus_namespace_conne message_id = uuid.uuid4() message = Message(content) message.time_to_live = timedelta(seconds=30) - await sender.send(message) + await sender.send_messages(message) time.sleep(30) async with sb_client.get_queue_receiver(servicebus_queue.name) as receiver: - messages = await receiver.receive(max_wait_time=10) + messages = await receiver.receive_messages(max_wait_time=10) assert not messages async with sb_client.get_queue_deadletter_receiver(servicebus_queue.name, idle_timeout=5, mode=ReceiveSettleMode.PeekLock) as receiver: @@ -790,7 +790,7 @@ async def test_async_queue_message_duplicate_detection(self, servicebus_namespac for i in range(5): message = Message(str(i)) message.properties.message_id = message_id - await sender.send(message) + await sender.send_messages(message) async with sb_client.get_queue_receiver(servicebus_queue.name, idle_timeout=5) as receiver: count = 0 @@ -813,10 +813,10 @@ async def test_async_queue_message_connection_closed(self, servicebus_namespace_ async with sb_client.get_queue_sender(servicebus_queue.name) as sender: content = str(uuid.uuid4()) message = Message(content) - await sender.send(message) + await sender.send_messages(message) async with sb_client.get_queue_receiver(servicebus_queue.name) as receiver: - messages = await receiver.receive(max_wait_time=10) + messages = await receiver.receive_messages(max_wait_time=10) assert len(messages) == 1 with pytest.raises(MessageSettleFailed): @@ -834,10 +834,10 @@ async def test_async_queue_message_expiry(self, servicebus_namespace_connection_ async with sb_client.get_queue_sender(servicebus_queue.name) as sender: content = str(uuid.uuid4()) message = Message(content) - await sender.send(message) + await sender.send_messages(message) async with sb_client.get_queue_receiver(servicebus_queue.name) as receiver: - messages = await receiver.receive(max_wait_time=10) + messages = await receiver.receive_messages(max_wait_time=10) assert len(messages) == 1 time.sleep(60) assert messages[0].expired @@ -847,7 +847,7 @@ async def test_async_queue_message_expiry(self, servicebus_namespace_connection_ await messages[0].renew_lock() async with sb_client.get_queue_receiver(servicebus_queue.name) as receiver: - messages = await receiver.receive(max_wait_time=30) + messages = await receiver.receive_messages(max_wait_time=30) assert len(messages) == 1 print_message(_logger, messages[0]) assert messages[0].header.delivery_count > 0 @@ -865,10 +865,10 @@ async def test_async_queue_message_lock_renew(self, servicebus_namespace_connect async with sb_client.get_queue_sender(servicebus_queue.name) as sender: content = str(uuid.uuid4()) message = Message(content) - await sender.send(message) + await sender.send_messages(message) async with sb_client.get_queue_receiver(servicebus_queue.name) as receiver: - messages = await receiver.receive(max_wait_time=10) + messages = await receiver.receive_messages(max_wait_time=10) assert len(messages) == 1 time.sleep(15) await messages[0].renew_lock() @@ -879,7 +879,7 @@ async def test_async_queue_message_lock_renew(self, servicebus_namespace_connect await messages[0].complete() async with sb_client.get_queue_receiver(servicebus_queue.name) as receiver: - messages = await receiver.receive(max_wait_time=10) + messages = await receiver.receive_messages(max_wait_time=10) assert len(messages) == 0 @pytest.mark.liveTest @@ -893,10 +893,10 @@ async def test_async_queue_message_receive_and_delete(self, servicebus_namespace async with sb_client.get_queue_sender(servicebus_queue.name) as sender: message = Message("Receive and delete test") - await sender.send(message) + await sender.send_messages(message) async with sb_client.get_queue_receiver(servicebus_queue.name, mode=ReceiveSettleMode.ReceiveAndDelete) as receiver: - messages = await receiver.receive(max_wait_time=10) + messages = await receiver.receive_messages(max_wait_time=10) assert len(messages) == 1 received = messages[0] print_message(_logger, received) @@ -913,7 +913,7 @@ async def test_async_queue_message_receive_and_delete(self, servicebus_namespace time.sleep(30) async with sb_client.get_queue_receiver(servicebus_queue.name) as receiver: - messages = await receiver.receive(max_wait_time=10) + messages = await receiver.receive_messages(max_wait_time=10) for m in messages: print_message(_logger, m) assert len(messages) == 0 @@ -931,13 +931,13 @@ async def test_async_queue_message_batch(self, servicebus_namespace_connection_s message = BatchMessage() for i in range(5): message.add(Message("Message no. {}".format(i))) - await sender.send(message) + await sender.send_messages(message) async with sb_client.get_queue_receiver(servicebus_queue.name) as receiver: - messages = await receiver.receive(max_wait_time=10) + messages = await receiver.receive_messages(max_wait_time=10) recv = True while recv: - recv = await receiver.receive(max_wait_time=10) + recv = await receiver.receive_messages(max_wait_time=10) messages.extend(recv) assert len(messages) == 5 @@ -962,9 +962,9 @@ async def test_async_queue_schedule_message(self, servicebus_namespace_connectio message = Message(content) message.properties.message_id = message_id message.scheduled_enqueue_time_utc = enqueue_time - await sender.send(message) + await sender.send_messages(message) - messages = await receiver.receive(max_wait_time=120) + messages = await receiver.receive_messages(max_wait_time=120) if messages: try: data = str(messages[0]) @@ -998,12 +998,12 @@ async def test_async_queue_schedule_multiple_messages(self, servicebus_namespace message_id_b = uuid.uuid4() message_b = Message(content) message_b.properties.message_id = message_id_b - tokens = await sender.schedule([message_a, message_b], enqueue_time) + tokens = await sender.schedule_messages([message_a, message_b], enqueue_time) assert len(tokens) == 2 - recv = await receiver.receive(max_wait_time=120) + recv = await receiver.receive_messages(max_wait_time=120) messages.extend(recv) - recv = await receiver.receive(max_wait_time=5) + recv = await receiver.receive_messages(max_wait_time=5) messages.extend(recv) if messages: try: @@ -1033,12 +1033,12 @@ async def test_async_queue_cancel_scheduled_messages(self, servicebus_namespace_ async with sb_client.get_queue_sender(servicebus_queue.name) as sender: message_a = Message("Test scheduled message") message_b = Message("Test scheduled message") - tokens = await sender.schedule([message_a, message_b], enqueue_time) + tokens = await sender.schedule_messages([message_a, message_b], enqueue_time) assert len(tokens) == 2 await sender.cancel_scheduled_messages(tokens) - messages = await receiver.receive(max_wait_time=120) + messages = await receiver.receive_messages(max_wait_time=120) assert len(messages) == 0 @pytest.mark.liveTest @@ -1055,11 +1055,11 @@ async def test_queue_message_amqp_over_websocket(self, servicebus_namespace_conn async with sb_client.get_queue_sender(servicebus_queue.name) as sender: assert sender._config.transport_type == TransportType.AmqpOverWebsocket message = Message("Test") - await sender.send(message) + await sender.send_messages(message) async with sb_client.get_queue_receiver(servicebus_queue.name, mode=ReceiveSettleMode.ReceiveAndDelete) as receiver: assert receiver._config.transport_type == TransportType.AmqpOverWebsocket - messages = await receiver.receive(max_wait_time=5) + messages = await receiver.receive_messages(max_wait_time=5) assert len(messages) == 1 def test_queue_message_http_proxy_setting(self): @@ -1095,10 +1095,10 @@ async def test_queue_message_settle_through_mgmt_link_due_to_broken_receiver_lin async with sb_client.get_queue_sender(servicebus_queue.name) as sender: message = Message("Test") - await sender.send(message) + await sender.send_messages(message) async with sb_client.get_queue_receiver(servicebus_queue.name) as receiver: - messages = await receiver.receive(max_wait_time=5) + messages = await receiver.receive_messages(max_wait_time=5) await receiver._handler.message_handler.destroy_async() # destroy the underlying receiver link assert len(messages) == 1 await messages[0].complete() diff --git a/sdk/servicebus/azure-servicebus/tests/async_tests/test_sessions_async.py b/sdk/servicebus/azure-servicebus/tests/async_tests/test_sessions_async.py index aa9dc7311efd..5645fa58e5a5 100644 --- a/sdk/servicebus/azure-servicebus/tests/async_tests/test_sessions_async.py +++ b/sdk/servicebus/azure-servicebus/tests/async_tests/test_sessions_async.py @@ -54,7 +54,7 @@ async def test_async_session_by_session_client_conn_str_receive_handler_peeklock async with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(3): message = Message("Handler message no. {}".format(i), session_id=session_id) - await sender.send(message) + await sender.send_messages(message) with pytest.raises(ServiceBusConnectionError): await sb_client.get_queue_receiver(servicebus_queue.name, idle_timeout=5)._open_with_retry() @@ -83,7 +83,7 @@ async def test_async_session_by_queue_client_conn_str_receive_handler_receiveand async with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(10): message = Message("Handler message no. {}".format(i), session_id=session_id) - await sender.send(message) + await sender.send_messages(message) messages = [] session = sb_client.get_queue_session_receiver(servicebus_queue.name, session_id=session_id, mode=ReceiveSettleMode.ReceiveAndDelete, idle_timeout=5) @@ -118,7 +118,7 @@ async def test_async_session_by_session_client_conn_str_receive_handler_with_sto async with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(10): message = Message("Stop message no. {}".format(i), session_id=session_id) - await sender.send(message) + await sender.send_messages(message) messages = [] session = sb_client.get_queue_session_receiver(servicebus_queue.name, session_id=session_id, idle_timeout=5) @@ -194,7 +194,7 @@ async def test_async_session_by_servicebus_client_iter_messages_with_retrieve_de session_id = str(uuid.uuid4()) async with sb_client.get_queue_sender(servicebus_queue.name) as sender: for message in [Message("Deferred message no. {}".format(i), session_id=session_id) for i in range(10)]: - await sender.send(message) + await sender.send_messages(message) count = 0 async with sb_client.get_queue_session_receiver(servicebus_queue.name, session_id=session_id, idle_timeout=5) as session: @@ -231,7 +231,7 @@ async def test_async_session_by_servicebus_client_iter_messages_with_retrieve_de session_id = str(uuid.uuid4()) async with sb_client.get_queue_sender(servicebus_queue.name) as sender: for message in [Message("Deferred message no. {}".format(i), session_id=session_id) for i in range(10)]: - await sender.send(message) + await sender.send_messages(message) count = 0 async with sb_client.get_queue_session_receiver(servicebus_queue.name, session_id=session_id, idle_timeout=5) as session: @@ -273,7 +273,7 @@ async def test_async_session_by_servicebus_client_iter_messages_with_retrieve_de session_id = str(uuid.uuid4()) async with sb_client.get_queue_sender(servicebus_queue.name) as sender: for message in [Message("Deferred message no. {}".format(i), session_id=session_id) for i in range(10)]: - await sender.send(message) + await sender.send_messages(message) count = 0 async with sb_client.get_queue_session_receiver(servicebus_queue.name, session_id=session_id, idle_timeout=5) as session: @@ -309,7 +309,7 @@ async def test_async_session_by_servicebus_client_iter_messages_with_retrieve_de async with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(10): message = Message("Deferred message no. {}".format(i), session_id=session_id) - await sender.send(message) + await sender.send_messages(message) session = sb_client.get_queue_session_receiver(servicebus_queue.name, session_id=session_id, idle_timeout=5) count = 0 @@ -339,16 +339,16 @@ async def test_async_session_by_servicebus_client_fetch_next_with_retrieve_deadl async with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(10): message = Message("Dead lettered message no. {}".format(i), session_id=session_id) - await sender.send(message) + await sender.send_messages(message) count = 0 - messages = await receiver.receive() + messages = await receiver.receive_messages() while messages: for message in messages: print_message(_logger, message) await message.dead_letter(reason="Testing reason", description="Testing description") count += 1 - messages = await receiver.receive() + messages = await receiver.receive_messages() assert count == 10 async with sb_client.get_queue_deadletter_receiver(servicebus_queue.name, idle_timeout=5) as session: @@ -375,15 +375,15 @@ async def test_async_session_by_servicebus_client_browse_messages_client(self, s async with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(5): message = Message("Test message no. {}".format(i), session_id=session_id) - await sender.send(message) + await sender.send_messages(message) session_id_2 = str(uuid.uuid4()) async with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(3): message = Message("Test message no. {}".format(i), session_id=session_id_2) - await sender.send(message) + await sender.send_messages(message) async with sb_client.get_queue_session_receiver(servicebus_queue.name, session_id=session_id) as receiver: - messages = await receiver.peek(5) + messages = await receiver.peek_messages(5) assert len(messages) == 5 assert all(isinstance(m, PeekMessage) for m in messages) for message in messages: @@ -392,7 +392,7 @@ async def test_async_session_by_servicebus_client_browse_messages_client(self, s message.complete() async with sb_client.get_queue_session_receiver(servicebus_queue.name, session_id=session_id_2) as receiver: - messages = await receiver.peek(5) + messages = await receiver.peek_messages(5) assert len(messages) == 3 @pytest.mark.liveTest @@ -409,9 +409,9 @@ async def test_async_session_by_servicebus_client_browse_messages_with_receiver( async with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(5): message = Message("Test message no. {}".format(i), session_id=session_id) - await sender.send(message) + await sender.send_messages(message) - messages = await receiver.peek(5) + messages = await receiver.peek_messages(5) assert len(messages) > 0 assert all(isinstance(m, PeekMessage) for m in messages) for message in messages: @@ -436,12 +436,12 @@ async def test_async_session_by_servicebus_client_renew_client_locks(self, servi async with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(locks): message = Message("Test message no. {}".format(i), session_id=session_id) - await sender.send(message) + await sender.send_messages(message) - messages.extend(await receiver.receive()) + messages.extend(await receiver.receive_messages()) recv = True while recv: - recv = await receiver.receive(max_wait_time=5) + recv = await receiver.receive_messages(max_wait_time=5) messages.extend(recv) try: @@ -475,7 +475,7 @@ async def test_async_session_by_conn_str_receive_handler_with_autolockrenew(self async with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(10): message = Message("{}".format(i), session_id=session_id) - await sender.send(message) + await sender.send_messages(message) renewer = AutoLockRenew() messages = [] @@ -527,10 +527,10 @@ async def test_async_session_message_connection_closed(self, servicebus_namespac async with sb_client.get_queue_sender(servicebus_queue.name) as sender: message = Message("test") message.session_id = session_id - await sender.send(message) + await sender.send_messages(message) async with sb_client.get_queue_session_receiver(servicebus_queue.name, session_id=session_id) as receiver: - messages = await receiver.receive(max_wait_time=10) + messages = await receiver.receive_messages(max_wait_time=10) assert len(messages) == 1 with pytest.raises(MessageSettleFailed): @@ -551,10 +551,10 @@ async def test_async_session_message_expiry(self, servicebus_namespace_connectio async with sb_client.get_queue_sender(servicebus_queue.name) as sender: message = Message("Testing expired messages") message.session_id = session_id - await sender.send(message) + await sender.send_messages(message) async with sb_client.get_queue_session_receiver(servicebus_queue.name, session_id=session_id) as receiver: - messages = await receiver.receive(max_wait_time=10) + messages = await receiver.receive_messages(max_wait_time=10) assert len(messages) == 1 print_message(_logger, messages[0]) await asyncio.sleep(60) #TODO: Was 30, but then lock isn't expired. @@ -569,7 +569,7 @@ async def test_async_session_message_expiry(self, servicebus_namespace_connectio await receiver.session.renew_lock() async with sb_client.get_queue_session_receiver(servicebus_queue.name, session_id=session_id) as receiver: - messages = await receiver.receive(max_wait_time=30) + messages = await receiver.receive_messages(max_wait_time=30) assert len(messages) == 1 print_message(_logger, messages[0]) #assert messages[0].header.delivery_count # TODO confirm this with service @@ -593,14 +593,14 @@ async def test_async_session_schedule_message(self, servicebus_namespace_connect message = Message(content, session_id=session_id) message.properties.message_id = message_id message.scheduled_enqueue_time_utc = enqueue_time - await sender.send(message) + await sender.send_messages(message) messages = [] renewer = AutoLockRenew() async with sb_client.get_queue_session_receiver(servicebus_queue.name, session_id=session_id) as receiver: renewer.register(receiver.session, timeout=140) - messages.extend(await receiver.receive(max_wait_time=120)) - messages.extend(await receiver.receive(max_wait_time=5)) + messages.extend(await receiver.receive_messages(max_wait_time=120)) + messages.extend(await receiver.receive_messages(max_wait_time=5)) if messages: data = str(messages[0]) assert data == content @@ -633,14 +633,14 @@ async def test_async_session_schedule_multiple_messages(self, servicebus_namespa message_id_b = uuid.uuid4() message_b = Message(content, session_id=session_id) message_b.properties.message_id = message_id_b - tokens = await sender.schedule([message_a, message_b], enqueue_time) + tokens = await sender.schedule_messages([message_a, message_b], enqueue_time) assert len(tokens) == 2 renewer = AutoLockRenew() async with sb_client.get_queue_session_receiver(servicebus_queue.name, session_id=session_id, prefetch=20) as receiver: renewer.register(receiver.session, timeout=140) - messages.extend(await receiver.receive(max_wait_time=120)) - messages.extend(await receiver.receive(max_wait_time=5)) + messages.extend(await receiver.receive_messages(max_wait_time=120)) + messages.extend(await receiver.receive_messages(max_wait_time=5)) if messages: data = str(messages[0]) assert data == content @@ -667,7 +667,7 @@ async def test_async_session_cancel_scheduled_messages(self, servicebus_namespac async with sb_client.get_queue_sender(servicebus_queue.name) as sender: message_a = Message("Test scheduled message", session_id=session_id) message_b = Message("Test scheduled message", session_id=session_id) - tokens = await sender.schedule([message_a, message_b], enqueue_time) + tokens = await sender.schedule_messages([message_a, message_b], enqueue_time) assert len(tokens) == 2 await sender.cancel_scheduled_messages(tokens) @@ -675,8 +675,8 @@ async def test_async_session_cancel_scheduled_messages(self, servicebus_namespac messages = [] async with sb_client.get_queue_session_receiver(servicebus_queue.name, session_id=session_id) as receiver: renewer.register(receiver.session, timeout=140) - messages.extend(await receiver.receive(max_wait_time=120)) - messages.extend(await receiver.receive(max_wait_time=5)) + messages.extend(await receiver.receive_messages(max_wait_time=120)) + messages.extend(await receiver.receive_messages(max_wait_time=5)) try: assert len(messages) == 0 except AssertionError: @@ -700,7 +700,7 @@ async def test_async_session_get_set_state_with_receiver(self, servicebus_namesp async with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(3): message = Message("Handler message no. {}".format(i), session_id=session_id) - await sender.send(message) + await sender.send_messages(message) async with sb_client.get_queue_session_receiver(servicebus_queue.name, session_id=session_id, idle_timeout=5) as session: assert await session.session.get_session_state() == None @@ -732,7 +732,7 @@ async def test_async_session_by_servicebus_client_list_sessions_with_receiver(se async with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(5): message = Message("Test message no. {}".format(i), session_id=session) - await sender.send(message) + await sender.send_messages(message) for session in sessions: async with sb_client.get_queue_session_receiver(servicebus_queue.name, session_id=session) as receiver: await receiver.session.set_session_state("SESSION {}".format(session)) @@ -762,7 +762,7 @@ async def test_async_session_by_servicebus_client_list_sessions_with_client(self async with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(5): message = Message("Test message no. {}".format(i), session_id=session) - await sender.send(message) + await sender.send_messages(message) for session in sessions: async with sb_client.get_queue_session_receiver(servicebus_queue.name, session_id=session) as receiver: await receiver.session.set_session_state("SESSION {}".format(session)) @@ -802,7 +802,7 @@ async def message_processing(sb_client): for session_id in sessions: async with sb_client.get_queue_sender(servicebus_queue.name) as sender: - await asyncio.gather(*[sender.send(Message("Sample message no. {}".format(i), session_id=session_id)) for i in range(20)]) + await asyncio.gather(*[sender.send_messages(Message("Sample message no. {}".format(i), session_id=session_id)) for i in range(20)]) receive_sessions = [message_processing(sb_client) for _ in range(concurrent_receivers)] await asyncio.gather(*receive_sessions, return_exceptions=True) @@ -823,7 +823,7 @@ async def test_async_session_basic_topic_subscription_send_and_receive(self, ser ) as sb_client: async with sb_client.get_topic_sender(topic_name=servicebus_topic.name) as sender: message = Message(b"Sample topic message", session_id='test_session') - await sender.send(message) + await sender.send_messages(message) async with sb_client.get_subscription_session_receiver( topic_name=servicebus_topic.name, @@ -867,7 +867,7 @@ async def test_async_session_connection_failure_is_idempotent(self, servicebus_n session_id = str(uuid.uuid4()) async with sb_client.get_queue_sender(servicebus_queue.name) as sender: - await sender.send(Message("test session sender", session_id=session_id)) + await sender.send_messages(Message("test session sender", session_id=session_id)) async with sb_client.get_queue_session_receiver(servicebus_queue.name, session_id=NEXT_AVAILABLE, idle_timeout=5) as receiver: messages = [] diff --git a/sdk/servicebus/azure-servicebus/tests/async_tests/test_subscriptions_async.py b/sdk/servicebus/azure-servicebus/tests/async_tests/test_subscriptions_async.py index 80ad74795ba1..70bff4a022f6 100644 --- a/sdk/servicebus/azure-servicebus/tests/async_tests/test_subscriptions_async.py +++ b/sdk/servicebus/azure-servicebus/tests/async_tests/test_subscriptions_async.py @@ -43,7 +43,7 @@ async def test_subscription_by_subscription_client_conn_str_receive_basic(self, ) as sb_client: async with sb_client.get_topic_sender(topic_name=servicebus_topic.name) as sender: message = Message(b"Sample topic message") - await sender.send(message) + await sender.send_messages(message) async with sb_client.get_subscription_receiver( topic_name=servicebus_topic.name, @@ -75,7 +75,7 @@ async def test_subscription_by_sas_token_credential_conn_str_send_basic(self, se async with sb_client.get_topic_sender(topic_name=servicebus_topic.name) as sender: message = Message(b"Sample topic message") - await sender.send(message) + await sender.send_messages(message) async with sb_client.get_subscription_receiver( topic_name=servicebus_topic.name, @@ -112,16 +112,16 @@ async def test_topic_by_servicebus_client_receive_batch_with_deadletter(self, se async with sb_client.get_topic_sender(servicebus_topic.name) as sender: for i in range(10): message = Message("Dead lettered message no. {}".format(i)) - await sender.send(message) + await sender.send_messages(message) count = 0 - messages = await receiver.receive() + messages = await receiver.receive_messages() while messages: for message in messages: print_message(_logger, message) count += 1 await message.dead_letter(reason="Testing reason", description="Testing description") - messages = await receiver.receive() + messages = await receiver.receive_messages() assert count == 10 diff --git a/sdk/servicebus/azure-servicebus/tests/async_tests/test_topic_async.py b/sdk/servicebus/azure-servicebus/tests/async_tests/test_topic_async.py index a481eab2c0bb..efd4cf48de65 100644 --- a/sdk/servicebus/azure-servicebus/tests/async_tests/test_topic_async.py +++ b/sdk/servicebus/azure-servicebus/tests/async_tests/test_topic_async.py @@ -41,7 +41,7 @@ async def test_topic_by_servicebus_client_conn_str_send_basic(self, servicebus_n ) as sb_client: async with sb_client.get_topic_sender(servicebus_topic.name) as sender: message = Message(b"Sample topic message") - await sender.send(message) + await sender.send_messages(message) @pytest.mark.liveTest @pytest.mark.live_test_only @@ -60,4 +60,4 @@ async def test_topic_by_sas_token_credential_conn_str_send_basic(self, servicebu ) as sb_client: async with sb_client.get_topic_sender(servicebus_topic.name) as sender: message = Message(b"Sample topic message") - await sender.send(message) + await sender.send_messages(message) diff --git a/sdk/servicebus/azure-servicebus/tests/stress_tests/stress_test_base.py b/sdk/servicebus/azure-servicebus/tests/stress_tests/stress_test_base.py index 554d1b380c8d..ec717e7ec06e 100644 --- a/sdk/servicebus/azure-servicebus/tests/stress_tests/stress_test_base.py +++ b/sdk/servicebus/azure-servicebus/tests/stress_tests/stress_test_base.py @@ -132,7 +132,7 @@ def _Send(self, sender, end_time): with sender: while end_time > datetime.utcnow(): message = self._ConstructMessage() - sender.send(message) + sender.send_messages(message) self.OnSend(self._state, message) self._state.total_sent += 1 time.sleep(self.send_delay) @@ -144,7 +144,7 @@ def _Receive(self, receiver, end_time): with receiver: while end_time > datetime.utcnow(): if self.receive_type == ReceiveType.pull: - batch = receiver.receive() + batch = receiver.receive_messages() elif self.receive_type == ReceiveType.push: batch = receiver diff --git a/sdk/servicebus/azure-servicebus/tests/test_queues.py b/sdk/servicebus/azure-servicebus/tests/test_queues.py index 2edc6f61af53..129c58ec580b 100644 --- a/sdk/servicebus/azure-servicebus/tests/test_queues.py +++ b/sdk/servicebus/azure-servicebus/tests/test_queues.py @@ -51,12 +51,12 @@ def test_receive_and_delete_reconnect_interaction(self, servicebus_namespace_con with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(5): - sender.send(Message("Message {}".format(i))) + sender.send_messages(Message("Message {}".format(i))) with sb_client.get_queue_receiver(servicebus_queue.name, mode=ReceiveSettleMode.ReceiveAndDelete, idle_timeout=10) as receiver: - batch = receiver.receive() + batch = receiver.receive_messages() count = len(batch) for message in receiver: @@ -75,7 +75,7 @@ def test_github_issue_6178(self, servicebus_namespace_connection_string, service with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(3): - sender.send(Message("Message {}".format(i))) + sender.send_messages(Message("Message {}".format(i))) with sb_client.get_queue_receiver(servicebus_queue.name, idle_timeout=60) as receiver: for message in receiver: @@ -100,7 +100,7 @@ def test_queue_by_queue_client_conn_str_receive_handler_peeklock(self, servicebu for i in range(10): message = Message("Handler message no. {}".format(i)) message.enqueue_sequence_number = i - sender.send(message) + sender.send_messages(message) receiver = sb_client.get_queue_receiver(servicebus_queue.name, idle_timeout=5) count = 0 @@ -128,7 +128,7 @@ def test_queue_by_queue_client_send_multiple_messages(self, servicebus_namespace for i in range(10): message = Message("Handler message no. {}".format(i)) messages.append(message) - sender.send(messages) + sender.send_messages(messages) with sb_client.get_queue_receiver(servicebus_queue.name, idle_timeout=5) as receiver: count = 0 @@ -153,7 +153,7 @@ def test_queue_by_queue_client_conn_str_receive_handler_receiveanddelete(self, s for i in range(10): message = Message("Handler message no. {}".format(i)) message.enqueue_sequence_number = i - sender.send(message) + sender.send_messages(message) messages = [] with sb_client.get_queue_receiver(servicebus_queue.name, @@ -191,7 +191,7 @@ def test_queue_by_queue_client_conn_str_receive_handler_with_stop(self, serviceb with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(10): message = Message("Stop message no. {}".format(i)) - sender.send(message) + sender.send_messages(message) messages = [] with sb_client.get_queue_receiver(servicebus_queue.name, idle_timeout=5) as receiver: @@ -232,7 +232,7 @@ def test_queue_by_servicebus_client_iter_messages_simple(self, servicebus_namesp with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(10): message = Message("Iter message no. {}".format(i)) - sender.send(message) + sender.send_messages(message) count = 0 for message in receiver: @@ -264,7 +264,7 @@ def test_queue_by_servicebus_conn_str_client_iter_messages_with_abandon(self, se with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(10): message = Message("Abandoned message no. {}".format(i)) - sender.send(message) + sender.send_messages(message) count = 0 for message in receiver: @@ -306,7 +306,7 @@ def test_queue_by_servicebus_client_iter_messages_with_defer(self, servicebus_na with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(10): message = Message("Deferred message no. {}".format(i)) - sender.send(message) + sender.send_messages(message) count = 0 for message in receiver: @@ -343,7 +343,7 @@ def test_queue_by_servicebus_client_iter_messages_with_retrieve_deferred_client( with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(10): message = Message("Deferred message no. {}".format(i)) - sender.send(message) + sender.send_messages(message) count = 0 for message in receiver: @@ -377,7 +377,7 @@ def test_queue_by_servicebus_client_iter_messages_with_retrieve_deferred_receive deferred_messages = [] for i in range(10): message = Message("Deferred message no. {}".format(i), session_id="test_session") - sender.send(message) + sender.send_messages(message) with sb_client.get_queue_receiver(servicebus_queue.name, idle_timeout=5, @@ -418,7 +418,7 @@ def test_queue_by_servicebus_client_iter_messages_with_retrieve_deferred_receive deferred_messages = [] for i in range(10): message = Message("Deferred message no. {}".format(i)) - sender.send(message) + sender.send_messages(message) with sb_client.get_queue_receiver(servicebus_queue.name, idle_timeout=5, @@ -462,7 +462,7 @@ def test_queue_by_servicebus_client_iter_messages_with_retrieve_deferred_receive with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(10): - sender.send(Message("Deferred message no. {}".format(i))) + sender.send_messages(Message("Deferred message no. {}".format(i))) deferred_messages = [] count = 0 @@ -504,7 +504,7 @@ def test_queue_by_servicebus_client_iter_messages_with_retrieve_deferred_not_fou with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(3): message = Message("Deferred message no. {}".format(i)) - sender.send(message) + sender.send_messages(message) count = 0 for message in receiver: @@ -539,16 +539,16 @@ def test_queue_by_servicebus_client_receive_batch_with_deadletter(self, serviceb with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(10): message = Message("Dead lettered message no. {}".format(i)) - sender.send(message) + sender.send_messages(message) count = 0 - messages = receiver.receive() + messages = receiver.receive_messages() while messages: for message in messages: print_message(_logger, message) count += 1 message.dead_letter(reason="Testing reason", description="Testing description") - messages = receiver.receive() + messages = receiver.receive_messages() assert count == 10 @@ -592,18 +592,18 @@ def test_queue_by_servicebus_client_receive_batch_with_retrieve_deadletter(self, with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(10): message = Message("Dead lettered message no. {}".format(i)) - sender.send(message) + sender.send_messages(message) count = 0 - messages = receiver.receive() + messages = receiver.receive_messages() while messages: for message in messages: print_message(_logger, message) message.dead_letter(reason="Testing reason", description="Testing description") count += 1 - messages = receiver.receive() + messages = receiver.receive_messages() - receiver.receive(1,5) + receiver.receive_messages(1,5) assert count == 10 @@ -635,7 +635,7 @@ def test_queue_by_servicebus_client_session_fail(self, servicebus_namespace_conn sb_client.get_queue_session_receiver(servicebus_queue.name, session_id="test")._open_with_retry() with sb_client.get_queue_sender(servicebus_queue.name) as sender: - sender.send(Message("test session sender", session_id="test")) + sender.send_messages(Message("test session sender", session_id="test")) @pytest.mark.liveTest @@ -651,10 +651,10 @@ def test_queue_by_servicebus_client_browse_messages_client(self, servicebus_name with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(5): message = Message("Test message no. {}".format(i)) - sender.send(message) + sender.send_messages(message) with sb_client.get_queue_receiver(servicebus_queue.name) as receiver: - messages = receiver.peek(5) + messages = receiver.peek_messages(5) assert len(messages) == 5 assert all(isinstance(m, PeekMessage) for m in messages) for message in messages: @@ -679,9 +679,9 @@ def test_queue_by_servicebus_client_browse_messages_with_receiver(self, serviceb with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(5): message = Message("Test message no. {}".format(i)) - sender.send(message) + sender.send_messages(message) - messages = receiver.peek(5) + messages = receiver.peek_messages(5) assert len(messages) > 0 assert all(isinstance(m, PeekMessage) for m in messages) for message in messages: @@ -704,7 +704,7 @@ def test_queue_by_servicebus_client_browse_empty_messages(self, servicebus_names idle_timeout=5, mode=ReceiveSettleMode.PeekLock, prefetch=10) as receiver: - messages = receiver.peek(10) + messages = receiver.peek_messages(10) assert len(messages) == 0 @@ -722,11 +722,11 @@ def test_queue_by_servicebus_client_fail_send_messages(self, servicebus_namespac with sb_client.get_queue_sender(servicebus_queue.name) as sender: with pytest.raises(MessageContentTooLarge): - sender.send(Message(too_large)) + sender.send_messages(Message(too_large)) half_too_large = "A" * int((1024 * 256) / 2) with pytest.raises(MessageContentTooLarge): - sender.send([Message(half_too_large), Message(half_too_large)]) + sender.send_messages([Message(half_too_large), Message(half_too_large)]) @pytest.mark.liveTest @pytest.mark.live_test_only @@ -747,12 +747,12 @@ def test_queue_by_servicebus_client_renew_message_locks(self, servicebus_namespa with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(locks): message = Message("Test message no. {}".format(i)) - sender.send(message) + sender.send_messages(message) - messages.extend(receiver.receive()) + messages.extend(receiver.receive_messages()) recv = True while recv: - recv = receiver.receive() + recv = receiver.receive_messages() messages.extend(recv) try: @@ -783,7 +783,7 @@ def test_queue_by_queue_client_conn_str_receive_handler_with_autolockrenew(self, with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(10): message = Message("{}".format(i)) - sender.send(message) + sender.send_messages(message) renewer = AutoLockRenew() messages = [] @@ -838,11 +838,11 @@ def test_queue_message_time_to_live(self, servicebus_namespace_connection_string message_id = uuid.uuid4() message = Message(content) message.time_to_live = timedelta(seconds=30) - sender.send(message) + sender.send_messages(message) time.sleep(30) with sb_client.get_queue_receiver(servicebus_queue.name, prefetch=5) as receiver: - messages = receiver.receive(5, max_wait_time=10) + messages = receiver.receive_messages(5, max_wait_time=10) assert not messages with sb_client.get_queue_deadletter_receiver( @@ -872,7 +872,7 @@ def test_queue_message_duplicate_detection(self, servicebus_namespace_connection for i in range(5): message = Message(str(i)) message.properties.message_id = message_id - sender.send(message) + sender.send_messages(message) with sb_client.get_queue_receiver(servicebus_queue.name, idle_timeout=5) as receiver: @@ -898,10 +898,10 @@ def test_queue_message_connection_closed(self, servicebus_namespace_connection_s with sb_client.get_queue_sender(servicebus_queue.name) as sender: content = str(uuid.uuid4()) message = Message(content) - sender.send(message) + sender.send_messages(message) with sb_client.get_queue_receiver(servicebus_queue.name) as receiver: - messages = receiver.receive(max_wait_time=10) + messages = receiver.receive_messages(max_wait_time=10) assert len(messages) == 1 with pytest.raises(MessageSettleFailed): @@ -921,10 +921,10 @@ def test_queue_message_expiry(self, servicebus_namespace_connection_string, serv with sb_client.get_queue_sender(servicebus_queue.name) as sender: content = str(uuid.uuid4()) message = Message(content) - sender.send(message) + sender.send_messages(message) with sb_client.get_queue_receiver(servicebus_queue.name) as receiver: - messages = receiver.receive(max_wait_time=10) + messages = receiver.receive_messages(max_wait_time=10) assert len(messages) == 1 time.sleep((messages[0].locked_until_utc - utc_now()).total_seconds()+1) assert messages[0].expired @@ -934,7 +934,7 @@ def test_queue_message_expiry(self, servicebus_namespace_connection_string, serv messages[0].renew_lock() with sb_client.get_queue_receiver(servicebus_queue.name) as receiver: - messages = receiver.receive(max_wait_time=30) + messages = receiver.receive_messages(max_wait_time=30) assert len(messages) == 1 print_message(_logger, messages[0]) assert messages[0].header.delivery_count > 0 @@ -954,10 +954,10 @@ def test_queue_message_lock_renew(self, servicebus_namespace_connection_string, with sb_client.get_queue_sender(servicebus_queue.name) as sender: content = str(uuid.uuid4()) message = Message(content) - sender.send(message) + sender.send_messages(message) with sb_client.get_queue_receiver(servicebus_queue.name) as receiver: - messages = receiver.receive(max_wait_time=10) + messages = receiver.receive_messages(max_wait_time=10) assert len(messages) == 1 time.sleep(15) messages[0].renew_lock() @@ -968,7 +968,7 @@ def test_queue_message_lock_renew(self, servicebus_namespace_connection_string, messages[0].complete() with sb_client.get_queue_receiver(servicebus_queue.name) as receiver: - messages = receiver.receive(max_wait_time=10) + messages = receiver.receive_messages(max_wait_time=10) assert len(messages) == 0 @@ -984,11 +984,11 @@ def test_queue_message_receive_and_delete(self, servicebus_namespace_connection_ with sb_client.get_queue_sender(servicebus_queue.name) as sender: message = Message("Receive and delete test") - sender.send(message) + sender.send_messages(message) with sb_client.get_queue_receiver(servicebus_queue.name, mode=ReceiveSettleMode.ReceiveAndDelete) as receiver: - messages = receiver.receive(max_wait_time=10) + messages = receiver.receive_messages(max_wait_time=10) assert len(messages) == 1 received = messages[0] print_message(_logger, received) @@ -1006,7 +1006,7 @@ def test_queue_message_receive_and_delete(self, servicebus_namespace_connection_ time.sleep(30) with sb_client.get_queue_receiver(servicebus_queue.name) as receiver: - messages = receiver.receive(max_wait_time=10) + messages = receiver.receive_messages(max_wait_time=10) for m in messages: print_message(_logger, m) assert len(messages) == 0 @@ -1031,13 +1031,13 @@ def message_content(): message = BatchMessage() for each in message_content(): message.add(each) - sender.send(message) + sender.send_messages(message) with sb_client.get_queue_receiver(servicebus_queue.name) as receiver: - messages =receiver.receive(max_wait_time=10) + messages =receiver.receive_messages(max_wait_time=10) recv = True while recv: - recv = receiver.receive(max_wait_time=10) + recv = receiver.receive_messages(max_wait_time=10) messages.extend(recv) assert len(messages) == 5 @@ -1064,9 +1064,9 @@ def test_queue_schedule_message(self, servicebus_namespace_connection_string, se message = Message(content) message.properties.message_id = message_id message.scheduled_enqueue_time_utc = enqueue_time - sender.send(message) + sender.send_messages(message) - messages = receiver.receive(max_wait_time=120) + messages = receiver.receive_messages(max_wait_time=120) if messages: try: data = str(messages[0]) @@ -1103,11 +1103,11 @@ def test_queue_schedule_multiple_messages(self, servicebus_namespace_connection_ message_id_b = uuid.uuid4() message_b = Message(content) message_b.properties.message_id = message_id_b - tokens = sender.schedule([message_a, message_b], enqueue_time) + tokens = sender.schedule_messages([message_a, message_b], enqueue_time) assert len(tokens) == 2 - messages = receiver.receive(max_wait_time=120) - messages.extend(receiver.receive(max_wait_time=5)) + messages = receiver.receive_messages(max_wait_time=120) + messages.extend(receiver.receive_messages(max_wait_time=5)) if messages: try: data = str(messages[0]) @@ -1138,12 +1138,12 @@ def test_queue_cancel_scheduled_messages(self, servicebus_namespace_connection_s with sb_client.get_queue_sender(servicebus_queue.name) as sender: message_a = Message("Test scheduled message") message_b = Message("Test scheduled message") - tokens = sender.schedule([message_a, message_b], enqueue_time) + tokens = sender.schedule_messages([message_a, message_b], enqueue_time) assert len(tokens) == 2 sender.cancel_scheduled_messages(tokens) - messages = receiver.receive(max_wait_time=120) + messages = receiver.receive_messages(max_wait_time=120) try: assert len(messages) == 0 except AssertionError: @@ -1167,11 +1167,11 @@ def test_queue_message_amqp_over_websocket(self, servicebus_namespace_connection with sb_client.get_queue_sender(servicebus_queue.name) as sender: assert sender._config.transport_type == TransportType.AmqpOverWebsocket message = Message("Test") - sender.send(message) + sender.send_messages(message) with sb_client.get_queue_receiver(servicebus_queue.name, mode=ReceiveSettleMode.ReceiveAndDelete) as receiver: assert receiver._config.transport_type == TransportType.AmqpOverWebsocket - messages = receiver.receive(max_wait_time=5) + messages = receiver.receive_messages(max_wait_time=5) assert len(messages) == 1 def test_queue_message_http_proxy_setting(self): @@ -1207,10 +1207,10 @@ def test_queue_message_settle_through_mgmt_link_due_to_broken_receiver_link(self with sb_client.get_queue_sender(servicebus_queue.name) as sender: message = Message("Test") - sender.send(message) + sender.send_messages(message) with sb_client.get_queue_receiver(servicebus_queue.name) as receiver: - messages = receiver.receive(max_wait_time=5) + messages = receiver.receive_messages(max_wait_time=5) receiver._handler.message_handler.destroy() # destroy the underlying receiver link assert len(messages) == 1 messages[0].complete() diff --git a/sdk/servicebus/azure-servicebus/tests/test_sb_client.py b/sdk/servicebus/azure-servicebus/tests/test_sb_client.py index 3f218584364f..b2b958543ec7 100644 --- a/sdk/servicebus/azure-servicebus/tests/test_sb_client.py +++ b/sdk/servicebus/azure-servicebus/tests/test_sb_client.py @@ -46,7 +46,7 @@ def test_sb_client_bad_credentials(self, servicebus_namespace, servicebus_queue, with client: with pytest.raises(ServiceBusError): with client.get_queue_sender(servicebus_queue.name) as sender: - sender.send(Message("test")) + sender.send_messages(Message("test")) @pytest.mark.liveTest @pytest.mark.live_test_only @@ -59,7 +59,7 @@ def test_sb_client_bad_namespace(self, **kwargs): with client: with pytest.raises(ServiceBusError): with client.get_queue_sender('invalidqueue') as sender: - sender.send(Message("test")) + sender.send_messages(Message("test")) @pytest.mark.liveTest @pytest.mark.live_test_only @@ -72,7 +72,7 @@ def test_sb_client_bad_entity(self, servicebus_namespace_connection_string, **kw with client: with pytest.raises(ServiceBusConnectionError): with client.get_queue_sender("invalid") as sender: - sender.send(Message("test")) + sender.send_messages(Message("test")) @pytest.mark.liveTest @pytest.mark.live_test_only @@ -85,11 +85,11 @@ def test_sb_client_readonly_credentials(self, servicebus_authorization_rule_conn with client: with client.get_queue_receiver(servicebus_queue.name) as receiver: - messages = receiver.receive(max_batch_size=1, max_wait_time=1) + messages = receiver.receive_messages(max_batch_size=1, max_wait_time=1) with pytest.raises(ServiceBusError): with client.get_queue_sender(servicebus_queue.name) as sender: - sender.send(Message("test")) + sender.send_messages(Message("test")) @pytest.mark.liveTest @pytest.mark.live_test_only @@ -103,13 +103,13 @@ def test_sb_client_writeonly_credentials(self, servicebus_authorization_rule_con with client: with pytest.raises(ServiceBusError): with client.get_queue_receiver(servicebus_queue.name) as receiver: - messages = receiver.receive(max_batch_size=1, max_wait_time=1) + messages = receiver.receive_messages(max_batch_size=1, max_wait_time=1) with client.get_queue_sender(servicebus_queue.name) as sender: - sender.send(Message("test")) + sender.send_messages(Message("test")) with pytest.raises(ValueError): - sender.send("cat") + sender.send_messages("cat") @pytest.mark.liveTest @pytest.mark.live_test_only @@ -125,4 +125,4 @@ def test_sb_client_incorrect_queue_conn_str(self, servicebus_queue_authorization with client: with pytest.raises(ServiceBusError): with client.get_queue_sender(wrong_queue.name) as sender: - sender.send(Message("test")) \ No newline at end of file + sender.send_messages(Message("test")) \ No newline at end of file diff --git a/sdk/servicebus/azure-servicebus/tests/test_sessions.py b/sdk/servicebus/azure-servicebus/tests/test_sessions.py index 3aab098b8275..dba7fcb8165a 100644 --- a/sdk/servicebus/azure-servicebus/tests/test_sessions.py +++ b/sdk/servicebus/azure-servicebus/tests/test_sessions.py @@ -54,7 +54,7 @@ def test_session_by_session_client_conn_str_receive_handler_peeklock(self, servi with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(3): message = Message("Handler message no. {}".format(i), session_id=session_id) - sender.send(message) + sender.send_messages(message) with pytest.raises(ServiceBusConnectionError): session = sb_client.get_queue_receiver(servicebus_queue.name, idle_timeout=5)._open_with_retry() @@ -82,7 +82,7 @@ def test_session_by_queue_client_conn_str_receive_handler_receiveanddelete(self, with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(10): message = Message("Handler message no. {}".format(i), session_id=session_id) - sender.send(message) + sender.send_messages(message) messages = [] with sb_client.get_queue_session_receiver(servicebus_queue.name, @@ -119,7 +119,7 @@ def test_session_by_session_client_conn_str_receive_handler_with_stop(self, serv with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(10): message = Message("Stop message no. {}".format(i), session_id=session_id) - sender.send(message) + sender.send_messages(message) messages = [] with sb_client.get_queue_session_receiver(servicebus_queue.name, session_id=session_id, idle_timeout=5) as session: @@ -191,7 +191,7 @@ def test_session_connection_failure_is_idempotent(self, servicebus_namespace_con session_id = str(uuid.uuid4()) with sb_client.get_queue_sender(servicebus_queue.name) as sender: - sender.send(Message("test session sender", session_id=session_id)) + sender.send_messages(Message("test session sender", session_id=session_id)) with sb_client.get_queue_session_receiver(servicebus_queue.name, session_id=NEXT_AVAILABLE, idle_timeout=5) as receiver: messages = [] @@ -234,7 +234,7 @@ def test_session_by_servicebus_client_iter_messages_with_retrieve_deferred_recei session_id = str(uuid.uuid4()) for i in range(10): message = Message("Deferred message no. {}".format(i), session_id=session_id) - sender.send(message) + sender.send_messages(message) count = 0 with sb_client.get_queue_session_receiver(servicebus_queue.name, @@ -275,7 +275,7 @@ def test_session_by_servicebus_client_iter_messages_with_retrieve_deferred_recei deferred_messages = [] session_id = str(uuid.uuid4()) messages = [Message("Deferred message no. {}".format(i), session_id=session_id) for i in range(10)] - sender.send(messages) + sender.send_messages(messages) count = 0 with sb_client.get_queue_session_receiver(servicebus_queue.name, @@ -322,7 +322,7 @@ def test_session_by_servicebus_client_iter_messages_with_retrieve_deferred_recei session_id = str(uuid.uuid4()) messages = [Message("Deferred message no. {}".format(i), session_id=session_id) for i in range(10)] for message in messages: - sender.send(message) + sender.send_messages(message) count = 0 with sb_client.get_queue_session_receiver(servicebus_queue.name, session_id=session_id, idle_timeout=5) as session: @@ -361,7 +361,7 @@ def test_session_by_servicebus_client_iter_messages_with_retrieve_deferred_clien with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(10): message = Message("Deferred message no. {}".format(i), session_id=session_id) - sender.send(message) + sender.send_messages(message) with sb_client.get_queue_session_receiver(servicebus_queue.name, session_id=session_id, idle_timeout=5) as session: count = 0 @@ -397,16 +397,16 @@ def test_session_by_servicebus_client_receive_with_retrieve_deadletter(self, ser with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(10): message = Message("Dead lettered message no. {}".format(i), session_id=session_id) - sender.send(message) + sender.send_messages(message) count = 0 - messages = receiver.receive() + messages = receiver.receive_messages() while messages: for message in messages: print_message(_logger, message) message.dead_letter(reason="Testing reason", description="Testing description") count += 1 - messages = receiver.receive() + messages = receiver.receive_messages() assert count == 10 with sb_client.get_queue_deadletter_receiver(servicebus_queue.name, @@ -432,19 +432,19 @@ def test_session_by_servicebus_client_browse_messages_client(self, servicebus_na with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(5): message = Message("Test message no. {}".format(i), session_id=session_id) - sender.send(message) + sender.send_messages(message) session_id_2 = str(uuid.uuid4()) with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(3): message = Message("Test message no. {}".format(i), session_id=session_id_2) - sender.send(message) + sender.send_messages(message) with pytest.raises(ServiceBusConnectionError): with sb_client.get_queue_receiver(servicebus_queue.name): - messages = sb_client.peek(5) + messages = sb_client.peek_messages(5) with sb_client.get_queue_session_receiver(servicebus_queue.name, session_id=session_id) as receiver: - messages = receiver.peek(5) + messages = receiver.peek_messages(5) assert len(messages) == 5 assert all(isinstance(m, PeekMessage) for m in messages) for message in messages: @@ -453,7 +453,7 @@ def test_session_by_servicebus_client_browse_messages_client(self, servicebus_na message.complete() with sb_client.get_queue_session_receiver(servicebus_queue.name, session_id=session_id_2) as receiver: - messages = receiver.peek(5) + messages = receiver.peek_messages(5) assert len(messages) == 3 @@ -472,9 +472,9 @@ def test_session_by_servicebus_client_browse_messages_with_receiver(self, servic with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(5): message = Message("Test message no. {}".format(i), session_id=session_id) - sender.send(message) + sender.send_messages(message) - messages = receiver.peek(5) + messages = receiver.peek_messages(5) assert len(messages) > 0 assert all(isinstance(m, PeekMessage) for m in messages) for message in messages: @@ -499,12 +499,12 @@ def test_session_by_servicebus_client_renew_client_locks(self, servicebus_namesp with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(locks): message = Message("Test message no. {}".format(i), session_id=session_id) - sender.send(message) + sender.send_messages(message) - messages.extend(receiver.receive()) + messages.extend(receiver.receive_messages()) recv = True while recv: - recv = receiver.receive(max_wait_time=5) + recv = receiver.receive_messages(max_wait_time=5) messages.extend(recv) try: @@ -544,7 +544,7 @@ def test_session_by_conn_str_receive_handler_with_autolockrenew(self, servicebus with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(10): message = Message("{}".format(i), session_id=session_id) - sender.send(message) + sender.send_messages(message) renewer = AutoLockRenew() messages = [] @@ -600,10 +600,10 @@ def test_session_message_connection_closed(self, servicebus_namespace_connection with sb_client.get_queue_sender(servicebus_queue.name) as sender: message = Message("test") message.session_id = session_id - sender.send(message) + sender.send_messages(message) with sb_client.get_queue_session_receiver(servicebus_queue.name, session_id=session_id) as receiver: - messages = receiver.receive(max_wait_time=10) + messages = receiver.receive_messages(max_wait_time=10) assert len(messages) == 1 with pytest.raises(MessageSettleFailed): @@ -624,10 +624,10 @@ def test_session_message_expiry(self, servicebus_namespace_connection_string, se with sb_client.get_queue_sender(servicebus_queue.name) as sender: message = Message("Testing expired messages") message.session_id = session_id - sender.send(message) + sender.send_messages(message) with sb_client.get_queue_session_receiver(servicebus_queue.name, session_id=session_id) as receiver: - messages = receiver.receive(max_wait_time=10) + messages = receiver.receive_messages(max_wait_time=10) assert len(messages) == 1 print_message(_logger, messages[0]) time.sleep(60) @@ -643,7 +643,7 @@ def test_session_message_expiry(self, servicebus_namespace_connection_string, se receiver.session.renew_lock() with sb_client.get_queue_session_receiver(servicebus_queue.name, session_id=session_id) as receiver: - messages = receiver.receive(max_wait_time=30) + messages = receiver.receive_messages(max_wait_time=30) assert len(messages) == 1 print_message(_logger, messages[0]) #assert messages[0].header.delivery_count # TODO confirm this with service @@ -669,12 +669,12 @@ def test_session_schedule_message(self, servicebus_namespace_connection_string, message = Message(content, session_id=session_id) message.properties.message_id = message_id message.scheduled_enqueue_time_utc = enqueue_time - sender.send(message) + sender.send_messages(message) messages = [] count = 0 while not messages and count < 12: - messages = receiver.receive(max_wait_time=10) + messages = receiver.receive_messages(max_wait_time=10) receiver.session.renew_lock() count += 1 @@ -708,14 +708,14 @@ def test_session_schedule_multiple_messages(self, servicebus_namespace_connectio message_id_b = uuid.uuid4() message_b = Message(content, session_id=session_id) message_b.properties.message_id = message_id_b - tokens = sender.schedule([message_a, message_b], enqueue_time) + tokens = sender.schedule_messages([message_a, message_b], enqueue_time) assert len(tokens) == 2 messages = [] count = 0 while len(messages) < 2 and count < 12: receiver.session.renew_lock() - messages = receiver.receive(max_wait_time=15) + messages = receiver.receive_messages(max_wait_time=15) time.sleep(5) count += 1 @@ -743,7 +743,7 @@ def test_session_cancel_scheduled_messages(self, servicebus_namespace_connection with sb_client.get_queue_sender(servicebus_queue.name) as sender: message_a = Message("Test scheduled message", session_id=session_id) message_b = Message("Test scheduled message", session_id=session_id) - tokens = sender.schedule([message_a, message_b], enqueue_time) + tokens = sender.schedule_messages([message_a, message_b], enqueue_time) assert len(tokens) == 2 sender.cancel_scheduled_messages(tokens) @@ -751,7 +751,7 @@ def test_session_cancel_scheduled_messages(self, servicebus_namespace_connection messages = [] count = 0 while not messages and count < 13: - messages = receiver.receive(max_wait_time=10) + messages = receiver.receive_messages(max_wait_time=10) receiver.session.renew_lock() count += 1 assert len(messages) == 0 @@ -771,7 +771,7 @@ def test_session_get_set_state_with_receiver(self, servicebus_namespace_connecti with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(3): message = Message("Handler message no. {}".format(i), session_id=session_id) - sender.send(message) + sender.send_messages(message) with sb_client.get_queue_session_receiver(servicebus_queue.name, session_id=session_id, idle_timeout=5) as session: assert session.session.get_session_state() == None @@ -804,7 +804,7 @@ def test_session_by_servicebus_client_list_sessions_with_receiver(self, serviceb with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(5): message = Message("Test message no. {}".format(i), session_id=session_id) - sender.send(message) + sender.send_messages(message) for session_id in sessions: with sb_client.get_queue_session_receiver(servicebus_queue.name, session_id=session_id) as receiver: receiver.set_session_state("SESSION {}".format(session_id)) @@ -835,7 +835,7 @@ def test_session_by_servicebus_client_list_sessions_with_client(self, servicebus with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(5): message = Message("Test message no. {}".format(i), session_id=session) - sender.send(message) + sender.send_messages(message) for session in sessions: with sb_client.get_queue_session_receiver(servicebus_queue.name, session_id=session) as receiver: receiver.set_session_state("SESSION {}".format(session)) @@ -878,7 +878,7 @@ def message_processing(sb_client): with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(20): message = Message("Test message no. {}".format(i), session_id=session_id) - sender.send(message) + sender.send_messages(message) futures = [] with concurrent.futures.ThreadPoolExecutor(max_workers=concurrent_receivers) as thread_pool: @@ -902,7 +902,7 @@ def test_session_by_session_client_conn_str_receive_handler_peeklock_abandon(sel with sb_client.get_queue_sender(servicebus_queue.name) as sender: for i in range(3): message = Message("Handler message no. {}".format(i), session_id=session_id) - sender.send(message) + sender.send_messages(message) with sb_client.get_queue_session_receiver(servicebus_queue.name, session_id=session_id, prefetch=0, idle_timeout=5) as receiver: message = receiver.next() @@ -927,7 +927,7 @@ def test_session_basic_topic_subscription_send_and_receive(self, servicebus_name ) as sb_client: with sb_client.get_topic_sender(topic_name=servicebus_topic.name) as sender: message = Message(b"Sample topic message", session_id='test_session') - sender.send(message) + sender.send_messages(message) with sb_client.get_subscription_session_receiver( topic_name=servicebus_topic.name, @@ -954,4 +954,4 @@ def test_session_non_session_send_to_session_queue_should_fail(self, servicebus_ with sb_client.get_queue_sender(servicebus_queue.name) as sender: message = Message("This should be an invalid non session message") with pytest.raises(MessageSendFailed): - sender.send(message) + sender.send_messages(message) diff --git a/sdk/servicebus/azure-servicebus/tests/test_subscriptions.py b/sdk/servicebus/azure-servicebus/tests/test_subscriptions.py index 3ee380d50f76..980e813b890a 100644 --- a/sdk/servicebus/azure-servicebus/tests/test_subscriptions.py +++ b/sdk/servicebus/azure-servicebus/tests/test_subscriptions.py @@ -42,7 +42,7 @@ def test_subscription_by_subscription_client_conn_str_receive_basic(self, servic ) as sb_client: with sb_client.get_topic_sender(topic_name=servicebus_topic.name) as sender: message = Message(b"Sample topic message") - sender.send(message) + sender.send_messages(message) with sb_client.get_subscription_receiver( topic_name=servicebus_topic.name, @@ -74,7 +74,7 @@ def test_subscription_by_sas_token_credential_conn_str_send_basic(self, serviceb with sb_client.get_topic_sender(topic_name=servicebus_topic.name) as sender: message = Message(b"Sample topic message") - sender.send(message) + sender.send_messages(message) with sb_client.get_subscription_receiver( topic_name=servicebus_topic.name, @@ -132,16 +132,16 @@ def test_subscription_by_servicebus_client_receive_batch_with_deadletter(self, s with sb_client.get_topic_sender(servicebus_topic.name) as sender: for i in range(10): message = Message("Dead lettered message no. {}".format(i)) - sender.send(message) + sender.send_messages(message) count = 0 - messages = receiver.receive() + messages = receiver.receive_messages() while messages: for message in messages: print_message(_logger, message) count += 1 message.dead_letter(reason="Testing reason", description="Testing description") - messages = receiver.receive() + messages = receiver.receive_messages() assert count == 10 diff --git a/sdk/servicebus/azure-servicebus/tests/test_topic.py b/sdk/servicebus/azure-servicebus/tests/test_topic.py index 22de2b6b546b..ecbffa3cba1a 100644 --- a/sdk/servicebus/azure-servicebus/tests/test_topic.py +++ b/sdk/servicebus/azure-servicebus/tests/test_topic.py @@ -40,7 +40,7 @@ def test_topic_by_servicebus_client_conn_str_send_basic(self, servicebus_namespa ) as sb_client: with sb_client.get_topic_sender(servicebus_topic.name) as sender: message = Message(b"Sample topic message") - sender.send(message) + sender.send_messages(message) @pytest.mark.liveTest @pytest.mark.live_test_only @@ -59,7 +59,7 @@ def test_topic_by_sas_token_credential_conn_str_send_basic(self, servicebus_name ) as sb_client: with sb_client.get_topic_sender(servicebus_topic.name) as sender: message = Message(b"Sample topic message") - sender.send(message) + sender.send_messages(message) @pytest.mark.skip(reason="Pending management apis") @pytest.mark.liveTest