Topic Compaction
Pulsar's topic compaction feature:
- Allows for faster "rewind" through topic logs
- Triggered automatically when the backlog reaches a certain size or can be triggered manually via the command line. See the Topic compaction cookbook
- Is conceptually and operationally distinct from . Topic compaction does, however, respect retention. If retention has removed a message from the message backlog of a topic, the message will also not be readable from the compacted topic ledger.
Topic compaction example: the stock ticker
When topic compaction is triggered via the CLI, Pulsar will iterate over the entire topic from beginning to end. For each key that it encounters the compaction routine will keep a record of the latest occurrence of that key.
After the initial compaction operation, the Pulsar that owns the topic is notified whenever any future changes are made to the compaction horizon and compacted backlog. When such changes occur: