Discarding expired messages

Component: SQL Server Transport
NuGet Package NServiceBus.SqlServer (3.x)
Target NServiceBus Version: 6.x


The messages with Time-To-Be-Received (TTBR) set are stored in the queue table just like regular messages. The only difference is that the Expires column is set to the time (in UTC) when the message expires. The calculation of expiry time is done on the database level so that clock drifts between endpoints don't affect the TTBR.


The messages with elapsed Time-To-Be-Received (TTBR) are ignored by the message pump whose receive query has a where clause that excludes expired messages.

The expired messages are removed from the queue by a scheduled job which runs every 5 minutes. Each run the job attempts to remove all expired messages, in batches, using series a delete statements. Each batch is limited to 10000 messages.

Last modified