<commit_before>---
title: Discarding Old Messages
summary: Automatically discard messages if they have not been processed within a given period of time.
tags:
- Message Expiration
- TimeToBeReceived
redirects:
- nservicebus/how-do-i-discard-old-messages
---

A message sent through the Particular Service Platform may have TTBR (TimeToBeReceived) set, according to the users’ decision. TTBR indicates to the platform that a delayed message will be discarded, instead of processed, if not handled after a specified period of time. A discarded message might no longer have any business value, and discarding it frees up storage, CPU and memory resources. 

This is important mainly in environments with high volumes of messages where there is little business value in processing a delayed message since it will already be replaced by a newer, more relevant version.

Only messages that have not been handled will have the TTBR set. A failed message moved to the error queue or a successfully handled message, including its possible audit message, is considered handled. By removing TTBR from handled messages we  assure that no message will be lost after it has been processed. The TTBR from the original message can always be inspected by looking at the `NServiceBus.TimeToBeReceived` [header](/nservicebus/messaging/message-headers).

If a message cannot be received by the target process in the given time frame, including all time in queues and in transit, you may want to discard it by using TimeToBeReceived.


To discard a message when a specific time interval has elapsed:

## Using an Attribute
<commit_msg>Update discard-old-messages.md<commit_after>---
title: Discarding Old Messages
summary: Automatically discard messages if they have not been processed within a given period of time.
tags:
- Message Expiration
- TimeToBeReceived
redirects:
- nservicebus/how-do-i-discard-old-messages
---

A message sent through the Particular Service Platform may have TTBR (TimeToBeReceived) set, according to the users’ decision. TTBR indicates to the platform that a delayed message will be discarded, instead of processed, if not handled after a specified period of time. A discarded message might no longer have any business value, and discarding it frees up storage, CPU and memory resources. 

This is important mainly in environments with high volumes of messages where there is little business value in processing a delayed message since it will already be replaced by a newer, more relevant version.

Only messages that have not been handled will have the TTBR set. A failed message moved to the error queue or a successfully handled message, including its possible audit message, is considered handled. By removing TTBR from handled messages we  assure that no message will be lost after it has been processed. The TTBR from the original message can always be inspected by looking at the `NServiceBus.TimeToBeReceived` [header](/nservicebus/messaging/message-headers.md).

If a message cannot be received by the target process in the given time frame, including all time in queues and in transit, you may want to discard it by using TimeToBeReceived.


To discard a message when a specific time interval has elapsed:

## Using an Attribute

{'fraction_non_alphanumeric': 0.037561576354679806, 'fraction_numerical': 0.0, 'mean_word_length': 4.720070422535211, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3391603', 'n_tokens_mistral': 763, 'n_tokens_neox': 731, 'n_words': 477}