Sending
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.
Receiving
Messages with Time-To-Be-Received (TTBR) specified are pushed through the message pump, just like regular messages, regardless of if their TTBR already elapsed or not. The receive query returns the difference between the expiry time and the current UTC time in the database so that the transport can make a decision if a given message has expired. Calculating the difference on the database level prevents the TTBR feature from being affected by potential clock drift of machines running sender and receiver endpoints.
In addition, 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 delete
statements. Each batch is limited to 10000 messages.