EcovadisCode / Ev.ServiceBus

A wrapper to use Azure Service Bus in a ASP.NET Core project
MIT License
20 stars 9 forks source link

Batch calculation API #56

Closed michalkorecki closed 1 year ago

michalkorecki commented 1 year ago

Adds IMessageBatcher which splits incoming message set into batches, each of which can be later sent as single ASB API call. Batching uses ServiceBusMessageBatch internally to split basing on maximum allowed message size (256k for standard tier ASB) or message count hard-limit per transaction (100).

IMessageBatcher can be also used to go around a bug in DispatchSender, where message partitioning does not take size limit into account. Bug can be replicated with Examples/send_40x7k_nonbatched.js fetch API call (assumes standard ASB tier).

benspeth commented 1 year ago

instead of providing a messagebatcher interface. Can you implement this logic directly into the DispatchSender class ?

michalkorecki commented 1 year ago

instead of providing a messagebatcher interface. Can you implement this logic directly into the DispatchSender class ?

Intention behind IMessageBatcher was to allow caller to know batches composition before dispatch is called (which might be in two different processes), so I'd prefer to keep it public. IMO replacing DispatchSender current batching logic with IMessageBatcher would be the most beneficial: size limit bug will be fixed and grouping code will be consolidated. Thoughts?

benspeth commented 1 year ago

The requirement behind this code is too specific, to be a valuable addition on this nuget