Azure / azure-service-bus

☁️ Azure Service Bus service issue tracking and samples
https://azure.microsoft.com/services/service-bus
MIT License
580 stars 775 forks source link

Cannot write large messages (>1MB) to Premium Partitioned Namespace #703

Closed evt-jonny closed 2 months ago

evt-jonny commented 2 months ago

Description

We have been looking into switching to a premium, partitioned service bus namespace in order to deal with throughput issues we are seeing with our current non-partitioned namespace.

We receive an error when trying to write a message larger than 1MB to a topic or queue in this new namespace, even when the topic/queue is configured to allow message sizes up to 10MB.

Actual Behavior

Azure.Messaging.ServiceBus.ServiceBusException
 HResult=0x80131500
 Message=The message (id:64923656, size:4194312 bytes) is larger than is currently allowed (1048576 bytes).
 Source=Azure.Messaging.ServiceBus
 StackTrace:
  at Azure.Messaging.ServiceBus.Amqp.AmqpSender.<SendBatchInternalAsync>d__23.MoveNext()
  at Azure.Messaging.ServiceBus.Amqp.AmqpSender.<SendBatchInternalAsync>d__23.MoveNext()
  at Azure.Messaging.ServiceBus.Amqp.AmqpSender.<>c.<<SendAsync>b__24_0>d.MoveNext()
  at Azure.Messaging.ServiceBus.ServiceBusRetryPolicy.<>c__22`1.<<RunOperation>b__22_0>d.MoveNext()
  at System.Threading.Tasks.ValueTask`1.get_Result()
  at Azure.Messaging.ServiceBus.ServiceBusRetryPolicy.<RunOperation>d__23`2.MoveNext()
  at Azure.Messaging.ServiceBus.ServiceBusRetryPolicy.<RunOperation>d__23`2.MoveNext()
  at System.Threading.Tasks.ValueTask`1.get_Result()
  at Azure.Messaging.ServiceBus.ServiceBusRetryPolicy.<RunOperation>d__22`1.MoveNext()
  at Azure.Messaging.ServiceBus.Amqp.AmqpSender.<SendAsync>d__24.MoveNext()
  at Azure.Messaging.ServiceBus.ServiceBusSender.<SendMessagesAsync>d__26.MoveNext()
  at Azure.Messaging.ServiceBus.ServiceBusSender.<SendMessageAsync>d__25.MoveNext()
  at Program.<<Main>$>d__0.MoveNext() in J:\working\asb-sendmessages\asb-sendmessages\Program.cs:line 22
  at Program.<<Main>$>d__0.MoveNext() in J:\working\asb-sendmessages\asb-sendmessages\Program.cs:line 31

Expected Behavior

We should still be able to write large messages to partitioned queues and topics. The documentation has no mention of this limitation when switching to a partitioned namespace.

Reproduction

The follow program works fine on a non-partitioned namespace and fails on a partitioned namespace with the above error:

using Azure.Messaging.ServiceBus;
using System.Text;

// the client that owns the connection and can be used to create senders and receivers
ServiceBusClient client;

// the sender used to publish messages to the queue
ServiceBusSender sender;

var clientOptions = new ServiceBusClientOptions()
{
    TransportType = ServiceBusTransportType.AmqpWebSockets
};
client = new ServiceBusClient("<NAMESPACE-CONNECTION-STRING>", clientOptions);
sender = client.CreateSender("test1");

var message = new ServiceBusMessage(Encoding.UTF8.GetBytes(new string('A', 1024 * 1024 * 4)));

try
{
    await sender.SendMessageAsync(message);
    Console.WriteLine($"A message has been published to the queue.");
}
finally
{
    // Calling DisposeAsync on client types is required to ensure that network
    // resources and other unmanaged objects are properly cleaned up.
    await sender.DisposeAsync();
    await client.DisposeAsync();
}

Console.WriteLine("Press any key to end the application");
Console.ReadKey();
EldertGrootenboer commented 2 months ago

This has been addressed in our current release. This release will be rolled out soon and should be available in all regions in ~6 weeks.