Outbox Outgoing Messages Dispatch Phase

In the Outbox flow diagram here:

I was wondering what the approach to transport mechanics and persistence operations are for “Step #8. Send messages.” and “Step #9. Set as Sent”
image

  • 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.

Thanks!
Mike

Hi Mike,

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:

Transport Batching
Amazon SQS Yes
ASB Yes
ASQ No
RabbitMQ No
SQL Server Yes

Hope that helps,
Kind regards,
Laila

1 Like

Hi Mike,

It seems like I overlooked something when answering. There’s an additional behavior being injected into the pipeline that actually forces all operations to be handled in isolation for the outbox.

The batching capabilities per transport still apply, they are just not used in the case of the Outbox.

Kind regards,
Laila