Skip to content

Conversation

@guoxdxdxd
Copy link

• Added SucceedMessageExpiredAfter and FailedMessageExpiredAfter properties to TopicAttribute for configuring expiration times of successful and failed messages.
• Updated ISubscribeExecutor implementation to apply expiration times based on topic attribute settings.
• Modified method signatures of SetSuccessfulState and SetFailedState to include expiration time parameters.
• Optimized message expiration logic to prioritize configuration values from topic attributes; fallback to global defaults if not specified.

Description:

In some scenarios, it may be necessary to customize the expiration time for a specific topic. For example, less important messages in large quantities may have shorter expiration times, while very important messages may require longer expiration times. Configuring expiration times per individual topic allows for more flexibility to meet user requirements.

Changes:
• Added expiration time settings in TopicAttribute.
• Updated SubscribeExecutor to retrieve custom configuration.

Checklist:

  • I have tested my changes locally
  • I have added necessary documentation (if applicable)
  • I have updated the relevant tests (if applicable)
  • My changes follow the project's code style guidelines

•	Added SucceedMessageExpiredAfter and FailedMessageExpiredAfter properties to TopicAttribute for configuring expiration times of successful and failed messages.
•	Updated ISubscribeExecutor implementation to apply expiration times based on topic attribute settings.
•	Modified method signatures of SetSuccessfulState and SetFailedState to include expiration time parameters.
•	Optimized message expiration logic to prioritize configuration values from topic attributes; fallback to global defaults if not specified.
@yang-xiaodong
Copy link
Member

Sorry, this feature was not approved because I don't consider it a valid or common requirement. For your needs, could you set a maximum value and then start a background thread to delete some messages?

@guoxdxdxd
Copy link
Author

Sorry, this feature was not approved because I don't consider it a valid or common requirement. For your needs, could you set a maximum value and then start a background thread to delete some messages?

I believe that data created by CAP should be maintained as much as possible within CAP itself.
In my current scenario, which is relatively complex, maintaining it via attributes seems to be the least costly approach.
Alternatively, we might want to reconsider whether this requirement is actually reasonable.

@demorgi
Copy link
Contributor

demorgi commented Oct 29, 2025

You can use the consumer filter to decide not to process the message based on your logic.
https://cap.dotnetcore.xyz/user-guide/en/cap/filter/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants