Just a second...

Automatic topic removal

Automatic topic removal

You can use an automatic topic removal policy to remove topics when a set of conditions you specify is met.

A simple use case would be a policy that automatically removes a topic if it has not been updated for a day.

A policy can remove the topic it applies to, or a set of topics specified with a path selector. For example, a policy could say that if topic a has not been updated for a day, topics b/1 and b/2 get removed.

An automatic topic removal policy is set with the REMOVAL topic property. The property is specified with an expression including the conditions and the optional selector specifying topics to remove.

See Removing topics automatically for details.

Considerations

Consider the following factors when using automatic topic removal:
  • If persistence is not enabled for a topic, the topic will be removed when a server shuts down, regardless of the removal policy.
  • If persistence is enabled for a topic, the topic's removal policy will persist. After a server is shut down and restarted, the removal policy will continue to be evaluated.
  • Policies are evaluated every few seconds, so a time-based removal policy may not be applied at the exact second specified.
  • Automatic topic removal is supported for replicated topics and for topics fanned out to secondary servers using the fan-out feature. The removal policy conditions will be evaluated as a whole across the cluster and at downstream fan-out servers.
  • Removal policy conditions take into account reference topics created from the monitored topic by a topic view.
  • If a reference topic created by a topic view is fanned out to a secondary server, sessions subscribed to the replica of the reference topic at the secondary server do not count towards the total subscriptions for the source topic with the removal policy.
  • If your application requires a private topic for each user/principal, you can use Topic ownership with an automatic topic removal policy to remove the topic when the user stops being active.