Azure / azure-sdk-for-python

This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.
MIT License
4.64k stars 2.84k forks source link

Cannot send messages larger than 1MB using ServiceBusClient and ServiceBusMessage with premium tier #29568

Closed RafaelAZV closed 1 year ago

RafaelAZV commented 1 year ago

Describe the bug I want to send payloads larger than 1MB using the SB premium tier. According to the docs, by using the premium tier, the message limit size is 100MB. I already configured manually my topic to the message max size of 100MB. However, when I send a message larger than 1MB using ServiceBusMessage, I get an exception with azure.servicebus.exceptions.MessageSizeExceededError: The received message (delivery-id:1, size:1113653 bytes) exceeds the limit (1048576 bytes) currently allowed on the link.

To Reproduce Steps to reproduce the behavior:

  1. Create a ServiceBusClient
  2. Create a payload with more than 1MB
  3. Attempt to send the message

The following code can reproduce the exception I am having:

from azure.servicebus import ServiceBusClient, ServiceBusMessage

conn_str = "<conn_str>"
client = ServiceBusClient.from_connection_string(conn_str)

payload = ["a"] * 5000000
payload = "".join(payload).encode()
message = ServiceBusMessage(body=payload)

with client:
    sender = client.get_queue_sender("<topic_name>")
    sender.send_messages(message)

Expected behavior Since the limit on my ServiceBus is 100MB, I expected the message to be send successfully

Screenshots The configuration of my topic

image

Additional context Additional Trace:

Traceback (most recent call last): File "/home/rafael/.local/lib/python3.10/site-packages/azure/servicebus/_base_handler.py", line 402, in _do_retryable_operation return operation(**kwargs) File "/home/rafael/.local/lib/python3.10/site-packages/azure/servicebus/_servicebus_sender.py", line 276, in _send self._handler.send_message(message.message) File "/home/rafael/.local/lib/python3.10/site-packages/uamqp/client.py", line 748, in send_message raise errors.ClientMessageError(exception, info=details) uamqp.errors.ClientMessageError: ErrorCodes.LinkMessageSizeExceeded: The received message (delivery-id:1, size:1113653 bytes) exceeds the limit (1048576 bytes) currently allowed on the link.

kashifkhan commented 1 year ago

Hi @RafaelAZV ,

I was not able to reproduce the error on my side. I set up a premium service bus with a queue set to accept the max size message (exactly like yours) and was able to send your payload that was provided.

I did notice you mention that your topic was set up to accept that size of message and in that case you will need servicebus_client.get_topic_sender. Just want to confirm there wasnt a mix up in my understanding.

RafaelAZV commented 1 year ago

Hi @kashifkhan, thank you for taking a look at my issue!

I think it is also worth to mention that my SB uses partitions (4 partitions). I made a quick experiment with the code I provided using a SB without partitions, and I was able to send the payload. Is this an expected behavior?

image

Could you try to reproduce using a SB with 2 or more partitions?

kashifkhan commented 1 year ago

Hi @RafaelAZV, I was able to repro after setting up partitions. Ive asked the question to the service bus team and will respond back as soon as I hear from them.

RafaelAZV commented 1 year ago

@kashifkhan ok, thank you very much!

kashifkhan commented 1 year ago

Hi @RafaelAZV, I got word from the service bus team that sending large messages to partitioned entities is not supported at the moment, its something they will address by the time partitioned namespaces are GA. Thanks :)

ghost commented 1 year ago

Hi @RafaelAZV. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.

ghost commented 1 year ago

Hi @RafaelAZV, since you haven’t asked that we “/unresolve” the issue, we’ll close this out. If you believe further discussion is needed, please add a comment “/unresolve” to reopen the issue.

yvgopal commented 7 months ago

Partitioned namespaces feature is already in GA. But sending messages larger than 1 MB is not supported yet. It will be rolled out to production by the end of this month i.e. April 2024.