Just a second...

Handling subscriptions to missing topics

A client can use the TopicControl feature of the Unified API to handle subscription or fetch requests for topics that do not exist.

Registering a missing topic handler and dynamically adding topics

Required permissions: modify_topic, register_handler

You can use the TopicControl feature to dynamically create topics on demand when a client tries to subscribe or fetch a topic that does not exist.

The client can register itself as a handler for missing topics for any part of the topic tree. The client is notified of attempts to subscribe to or fetch topics that are subordinate to that topic and that do not exist. This enables the client to create the topics and notify the Diffusion™ server that the client operation subscribe or fetch can proceed.

Note: The handler is called only when a client attempts to subscribe or fetch using a single topic path. If another type of selector is used to subscribe to or fetch the topic, the handler is not notified.
Figure 1. Flow from a subscribing client to the client that handles a missing topic subscription The subscribing client subscribes to topic 'foo/missing' that does not exist. The Diffusion server notifies the handling client that has registered a handler against that branch of the topic tree. The handling client acts on this notification and tells the server when its action is complete by calling proceed or cancel. The Diffusion server responds to the subscribing client.

The missing topic handler is removed when the registering session is closed. If the registering session loses connection, it goes into DISCONNECTED state. When in DISCONNECTED state the handler remains active but cannot pass on the notifications to the client. In this case, cancel or proceed callbacks for these notifications might not function as expected because of timeouts. If the client then closes, these notifications are discarded.

To ensure that missing topic notifications are always received by your solution, you can use multiple clients to register missing topic handlers. Ensure that if any of these clients lose connection they go straight to CLOSED state by setting the reconnection timeout to zero. When the client loses connect it closes straight away, the handler is registered is removed, and further missing topic notifications are routed to a handler registered by another client.