Shawn de Wet
Shawn de Wet

Reputation: 5976

Max Number of Messages in NServiceBus Send

I'm not using NSB at the moment, but am evaluating it as a possible solution.

Is there a practical limit to the number of messages I can pass to NServiceBus' IBus.Send(params IMessage[] messages) command?

In my app I have always been batching messages in batches of a couple dozen...maybe 300 tops (think of the scenario of marketing emails that need to be sent). Individual messages are not large...about 500 bytes each on average. Now I have a new scenario (new tenant) who is batching up to 6000 messages (which raises a concern that in the future I can get an even bigger tenant processing 10s of thousands of marketing emails in a campaign).

I need to know how to handle this scenario with an NSB solution. I'm thinking the .Send method call would be a blocking one, blocked for as long as it takes MSMQ under the hood to queue up 6000 messages. But are there other practical concerns I should be aware of here? Would it be better if I were to rather iterate over the collection of messages and rather pass each one individually to the overload of IBus.Send that accepts a single message?

Its really just the sending side that I am concerned about here. The server side receives and processes each message individually and the sequence there does not matter.

Upvotes: 0

Views: 303

Answers (1)

Phil Sandler
Phil Sandler

Reputation: 28016

Version 5 of NServiceBus removed the ability to Send() multiple messages in one call:

http://docs.particular.net/nservicebus/upgradeguides/4to5#obsolete-sending-and-publishing-batches-of-messages-together-in-a-single-call

I wouldn't foresee any problem with looping over 6000 messages and sending them. You may need to ensure that MSMQ is configured to handle the number of messages and amount of space you may need, but based on your description I don't think you will need to change from the default settings.

I would recommend grabbing a demo license and doing some testing. It should be fairly easy to spin up a little test harness that produces that kind of message volume.

Upvotes: 1

Related Questions