I was wondering what the approach to transport mechanics and persistence operations are for “Step #8. Send messages.” and “Step #9. Set as Sent”
If the transport supports message batching, will NServiceBus leverage that functionality to batch the dispatch in the “Send Messages” step, or will it use immediate dispatch, once per message?
If message batching is used at the transport level for “Send Messages” step, what happens when the number of outgoing messages to dispatch exceed the message batching threshold of the underlying transport?
Is the persistence operation to update Dispatched and DispatchedAt columns as well as clear the Operations column explicitly done in a transaction?
I’ve been digging through some of the source code, but haven’t been able to determine an answer to these questions.
It really depends on the transport’s batching capabilities.
If the transport supports batching, the messages that need to be sent out, are sent out in batch. If the nr of messages exceeds the batch size, several batches will be used. For other transports, the messages are dispatched one by one.
The update of the Dispatched flag and the DispatchedAt date/time is handled by the persistence and this is in a single operation (this can be found in the OutboxPersister class of the persistence you’re using).
Here’s an overview of the batching capabilities across transports: