Just a second...

Removing topics with sessions

A client can specify that the Diffusion™ server removes a topic or topics after the client session closes or fails.

Required permissions: modify_topic

When a client registers that a branch of the topic tree be removed when its session closes, the following events occur:
  1. The client registers the removal request on a branch of the topic tree and passes in a topic tree handler.
    • The removal request is registered against a topic path. This is a path that identifies a branch of the topic tree, for example foo/bar. The removal request is registered for the branch of the topic tree, for example the topics foo/bar/baz and foo/bar/fred/qux are included in the specified branch of the topic tree.
    • You cannot register a removal request above or below an existing removal request. For example, if a client has registered a removal request against foo/bar/fred another client cannot register a removal request against foo/bar or foo/bar/fred/qux.
  2. The server validates the request and gives one of the following responses:
    • If the request is not valid, the Diffusion server calls the onError callback of the topic tree handler.

      For example, a registration request is not valid if it registers against a topic branch that is above or below a branch where an existing removal request is registered.

    • If the request is valid, the Diffusion server calls the OnActive callback of the topic tree handler and provides a Registration object to the client.
  3. If the client wants to deregister a removal request, it can call the onClose method of the Registration object for that removal request.
  4. Other clients can register removal requests against a topic that already has a removal request registered against it. For example, if one session on the Diffusion server has registered a removal request against foo/bar/baz, another session on the Diffusion server can also register a removal request against foo/bar/baz.
  5. When a client session closes or fails, if it has registered removal requests, one of the following things happens:
    • If there are still open sessions that have removal requests for the same branch of the topic tree, the Diffusion server takes no action.
    • If there are no open sessions that have removal requests for that branch of the topic tree, the Diffusion server removes all topics in that branch of the topic tree.
    Note: The client session must be in a closed state for a removal request to be acted upon. If a client becomes disconnected, the removal request is not acted upon until the reconnection timeout has elapsed and the client session is closed.

Remove topic requests and topic replication

If all sessions on a Diffusion server that have a removal request for a branch of the topic tree close, the topics are removed even if that topic is replicated and sessions on other Diffusion servers have removal requests registered against that part of the tree. When the topics are removed on the server, that change is replicated to all other servers that participate in replication for these topics.