-
Couldn't load subscription status.
- Fork 5.1k
Description
Is your feature request related to a problem? Please describe.
As described in Azure/azure-service-bus-dotnet#539
The client allows to send a collection of messages (SendAsync(IList)) which is problematic when there's a large number of messages that would not fit into the maximum message size. As a result of that, an exception is thrown when the send operation is invoked.
Describe the solution you'd like
I'd like to write the following code without worrying about an MessageSizeExceededException
await messageSender.SendAsync(bigListOfMessages);But since there already a SendAsync method that takes IList<Message> one could name it SendChunkedAsync(), SendBatchAsync() or something else that doesn't conflict.
I'm thinking that this method would use the current SendAsync(IList<Message>) method to send it's chunks of Messages in order to pack them into as few AMPQ messages as possible.
Describe alternatives you've considered
-
I've tried to chunk the messages my self as described in this article but given that the
Sizeproperty of theMessageclass only accounts for body size. -
This is the my current solution from my understanding sends all the messages individually. Or at least it appears so on the when looking at the code.
var sendTasks = messages
.Select(m => messageSender.SendAsync(m))
.ToArray();
await Task.WaitAll(sendTasks);