-
Notifications
You must be signed in to change notification settings - Fork 280
Description
Problem
Currently the IServiceBusSenderWrapper implements SendAsync(ServiceBusMessage message..) and SendAsync(ServiceBusMessage[] messages, ..)
Whilst premium tiers of Azure Service Bus support message sizes of 100MB a batch can only be a max size of 1MB.
We're using Microsofts SendMessage**s**() implementation, it does not make use of ServiceBusMessageBatch which gives us a view on when we're exceeding the threshold.
Exceeding the size limits produces various exceptions
Running a batch >1MB through SendMessage**s**():
System.InvalidOperationException : The link 'G1:39496958:amqps://rev-recog-test.servicebus.windows.net/-e446fcba;0:5:6' is force detached by the broker because publisher(link34(39496966_G1)) received a batch message with no data in it. Detach origin: Publisher.
For troubleshooting information, see https://aka.ms/azsdk/net/servicebus/exceptions/troubleshoot.
(Try to) Create a message batch with a max batch size >1MB
System.ArgumentOutOfRangeException : Value is greater than the maximum allowed. (Parameter 'MaxSizeInBytes')
Solution
Proposal to use ServiceBusMessageBatch.TryAddMessage which will allow us to batch on size, not on number. A fallback solution if a single message exceeds the allowed batch size (1MB) to use SendAsync(ServiceBusMessage message, ..)
This will allow use to batch on size and but also produce messages up to Azure Service Bus allowed quotas.
(an inflight pr will allow us to make these changes with little impact as generic batches need to implement an IAmAMessageBatch interface)
Additional context
Ref : https://docs.azure.cn/en-us/service-bus-messaging/service-bus-quotas
