Why is azure service bus message size not enforced everywhere?

Ashish Sabne 0 Reputation points
2023-03-01T22:28:30.52+00:00

My organization has an application wherein we communicate between 2 API projects via Azure Service Bus messages. We just found out that the message size limit on the queue is 256kB, so for a large message, the system generates a MessageSizeExceededException. However, that limit does not seem to be enforced on my local machine as well as DEV, QA or UAT environments (all of which are on Azure) but only on PRODUCTION server. Why is that limit enforced selectively? Also, is there an alternative without having to breakup the original message, since that is not an option due to certain business scenarios?

Azure Service Bus
Azure Service Bus
An Azure service that provides cloud messaging as a service and hybrid integration.
594 questions
{count} votes

1 answer

Sort by: Most helpful
  1. MayankBargali-MSFT 70,016 Reputation points
    2023-03-02T05:08:44.5833333+00:00

    @Ashish Sabne Thanks for reaching out. As you are getting the MessageSizeExceededException so it looks like your production namespace is under the standard tier as 256 KB is the max message size supported in standard service bus.

    However, that limit does not seem to be enforced on my local machine as well as DEV, QA or UAT environments (all of which are on Azure) but only on PRODUCTION server. Why is that limit enforced selectively?

    When you mentioned that you don't observe the same behavior in the DEV, QA or UAT environments so I will suggest you to first verify which SKU is your namespace in different environment. In case if the SKU is same i.e. standard for all the environment then have you tested the same message content and size sending to different environment as it will behave the same and you should get the MessageSizeExceededException exception for the same message size/content and for the same standard SKU.

    Is there an alternative without having to breakup the original message, since that is not an option due to certain business scenarios

    You can either migrate your production namespace to premium namespace by migrating to premium option under your namespace and for more details please refer to this document.

    Alternative you can either break your original message or the pricing tier or use the claim check pattern described in this blog post if you're dealing with messages of size greater than the allowed size.

    Feel free to get back to me if you have any queries or concerns.

    Please accept as "Yes" if the answer is helpful so that it can help others in the community. If you need any help/clarification/concerns/follow up questions, then please click on "Add Comment" on my answer and provide more details.