As per NServiceBus Azure Cosmos DB persistence documentation, the outbox deduplication data is kept for 7 days by default. However, this can easily add hundreds of outbox documents in a day for a high volume transaction DB. I understand we can change the default settings to reduce the outbox ttl
. However, before doing that, I would like to understand the following:
ttl
of the outbox document to, say, 4 days? Does it mean if a message has failed, it can be only recovered for the next 4 days? If yes, is there a way to clean up the outbox record for the transactions that are successful immediately?What is the significance of keeping the outbox document for 7 days in Cosmos DB?
This is the default value. It's chosen to be on the safe side and ensure that no duplicates are reprocessed within 7 days, which is a fairly safe time range.
What is the impact of reducing the ttl of the outbox document to, say, 4 days?
If you reduce TTL to 4 days and there's a chance of a duplicate message arriving after that period, the duplicate will be processed rather than discarded.
Does it mean if a message has failed, it can be only recovered for the next 4 days?
The outbox feature is not about removing messages. It's used for de-duplication of the incoming messages to avoid unnecessary re-processing.
If yes, is there a way to clean up the outbox record for the transactions that are successful immediately?
You could set TTL to a very low value but then you're risking running into duplicate reprocessing as it's not about successful or unsuccessful incoming message processing but rather duplicates you cannot control. Not to mention that the outbox feature helps to reduce unnecessary handler execution upon incoming message retries in case dispatching has failed.