Messages cannot be larger than 65536 bytes
Asked Answered
T

2

8

I'm using Azure Queue to send emails. But for last time I'm getting exception about queue size limit up to 65536 bytes even after cheking the message size.

enter image description here

Terryl answered 16/9, 2016 at 10:9 Comment(0)
A
18

While it is true that the maximum size of a message can be 64KB however Azure uses UTF16 encoding to store the data thus for each byte of data that you provide, Azure Storage uses 2 bytes to store that data.

What this means is that you can essentially store up to 32KB of data in a message in an Azure Queue. Because you're exceeding this 32KB limit, you're getting this error.

Administer answered 16/9, 2016 at 10:19 Comment(2)
There're many things you could do other than reducing the message size: 1) One way to reduce the message size is to apply some kind of compression on the message contents. However there're always a possibility that even after compression you may exceed this 32 KB limit 2) Store the message contents in blob storage and message will contain the blob URL. Then when you need to get the message, you simply fetch the blob from that URL. Since a blob can be of 200GB in size, I don't think you will run into the issue of 32KB limit.Administer
Or you could use a Service Bus azure.microsoft.com/en-us/documentation/articles/…Senskell
A
2

A string message will be Base64 encoded before being sent thus increasing its length by about a third.

Therefore the maximum length of message string you can submit is 49152 which equates to 65536, the maximum allowed.

The formula for calculating the Base64 encoded length can be found here: https://mcmap.net/q/117694/-base64-length-calculation

Adjacency answered 26/7, 2019 at 12:53 Comment(1)
Is this the reason when I try to put a fairly large JSON message in a queue in the Azure Portal, the check mark “Encode the message in the body in Base64” gets grayed out?Idealism

© 2022 - 2024 — McMap. All rights reserved.