Time-to-Live for Messages

The time-to-live (TTL) for messages means that messages persist in the partitions of a stream topic for a specific time period. During that time, messages can be read or re-read by consumers. Once the TTL for a message runs out, the message is marked for deletion.

Setting TTL for Message

Time-to-live for topic messages is set when creating or editing a stream. Because the TTL setting is specified at the stream-level, all messages in all topics associated with the stream will have the same TTL. The default TTL is 604,800 seconds or 7 days.

Deleting Expired Messages

Expired messages are deleted by an automatic process that runs at periodic intervals of TTL/10 and no later than 24 hours. For example:

  • If the TTL is set to 24 hours, expired messages are deleted once every 24 hours.
  • If the TTL is set to 7 days (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 (480 hours), expired messages are deleted once every 48 hours because 48 is greater than 24.

To immediately delete expired messages, run the maprcli command stream purge.

For More Information

  • See the maprcli stream create for information about creating streams.
  • See the maprcli stream edit for information about editing streams.
  • See the maprcli stream purge for information about purging expired topic messages.
  • See the MapR-ES Java API Library for the methods used to create and edit streams