You can’t send a batch of messages using
ServiceBusMessageBatch with NServiceBus but you can dispatch multiple messages concurrently and gain some throughput improvement. You’d need to send/publish messages w/o awaiting, collecting each send operation in a list and awaiting for all those to eventually complete.
var tasks = new List<Task>();
foreach (var item in items)
When dispatching messages, take into consideration wherever you do that inside or outside message handler. If outside message handler, you can go fairly wild with number of tasks. Inside message handler, you need to watch out for transport transaction mode the transport is configured with. If it’s
SendsAtomicWithReceive, you’ll be limited to maximum 100 messages. With
ReceiveOnly you’ll be able to surpass that limit but then you’re not sending the outgoing messages in a transaction with the incoming message. The choices, the decisions to make - depends on what you need more.