BrighterCommand / BrighterCommand/Brighter

[Feature] Azure Service Bus to use ServiceBusMessageBatch with fallback to SendMessage

Open
#3,694 2 comments 0 reactions 1 assignee Claimed by @mikechrisfreeman View on GitHub
.NET 0 - Backlog feature request help wanted V10.X v9
Dominant language
C#
Stars
2.5k
Forks
296
Avg merge
1d 11h
Merged PRs (30d)
21

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

Image

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.