Time-to-Live for Messages

Messages can persist in the partitions of a stream for as long as you need them to, and can be read or reread by consumers during that time. However, if you know that after a certain period of time the messages in a stream will no longer be needed, you can specify a length of time for messages to persist until they expire.

You can set this time in seconds with the -ttl parameter when you create or edit a stream. The default is 604,800 seconds, or 7 days.

Expired messages are deleted by an automatic process that runs at periodic intervals of TTL/10, with a minimum of 24 hours. Examples:
  • If the TTL is set to 24 hours, expired messages are deleted once every 24 hours.
  • If the TTL is set to 7 days (i.e. 168 hours, which is the default), expired messages are deleted once every 24 hours because 24 is greater than 168/10.
  • If the TTL is set to 20 days (i.e 480 hours), expired messages are deleted once every 48 hours because 48 is greater than 24.
If you want to delete expired messages immediately, you can run the command maprcli stream purge.