Skip to content

[FEATURE REQ] Support for safe batching with MessageSender #8440

@brolaugh

Description

@brolaugh

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

  1. I've tried to chunk the messages my self as described in this article but given that the Size property of the Message class only accounts for body size.

  2. 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);

Metadata

Metadata

Assignees

Labels

ClientThis issue is related to a non-management packageService AttentionWorkflow: This issue is responsible by Azure service team.Service Buscustomer-reportedIssues that are reported by GitHub users external to the Azure organization.feature-requestThis issue requires a new behavior in the product in order be resolved.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions