Azure Service Bus Premium - Message Size

Messaging is about small messages. You should keep your messages relatively small. If you have fat messages, you're doing it wrong. All valid statements, until you look closer at the Azure Service Bus Quotas information. The ones that are sometimes hard to digest would be:

  1. Message size for a queue/topic/subscription entity - 256KB
  2. Maximum header size - 64KB

It means up to 192KB for the payload. For the most scenarios, 192KB is a lot of data for a payload. If your message is slightly over that size, you're out of luck and will have to look into implementing a claim check pattern. Unfortunately, that mean the message is handled by more than a single service (Azure Service Bus and Azure Storage). Till recently that was the only option. Facing size limit, this is where you might reconsider Azure Service Bus Standard tier and trade your old ride for a new one: Premium Tier.

Premium tier was added to handle addresses scale, performance, and availability. Now it can also handle messages large than 1MB. To be more specific, up to 1MB (according to the tests I've done).

var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
var queueName = "test";
if (!await namespaceManager.QueueExistsAsync(queueName))
{
	await namespaceManager.CreateQueueAsync(queueName);
	Console.WriteLine("Queue created");
}
else
{
	Console.WriteLine("Queue existed");
}
var factory = await MessagingFactory.CreateAsync(namespaceManager.Address, namespaceManager.Settings.TokenProvider);
var sender = await factory.CreateMessageSenderAsync(queueName);

// send a payload of 512KB
var msg1 = new BrokeredMessage(new string('A', 512 * 1024));
msg1.TimeToLive = TimeSpan.FromMinutes(2);

Console.WriteLine("Sending batch");
await sender.SendAsync(msg1);

enter image description here

Note: the maximum size I've managed to send was 1,013KB

enter image description here

No Comments