I have a control client that creates topics on demand (when a client subscribes to a topic that doesn't exist, it is created). I'm using MissingTopicHandler
to get notification when a client requests a topic that does not exist, and then I create it.
This works fine when my client subscribes to a concrete topic path such as >myTopic
, but not when a client subscribes to a wildcard topic path such as ?myTopic//
.
How can I do this?
When you subscribe to a topic selector as opposed to a topic path, the MissingTopicHandler will not be triggered unless the concrete topic that is used in your wildcard topic path is missing.
For your example, if a client subscribes to ?myTopic//
, and the topic myTopic
exists, no notification is sent. However, if the topic does not exist, then a topic missing notification is sent for this topic (if there is a MissingTopicHandler on this topic path).
For a subscription to a topic selector, there is no missing topic event notification for the children of topic myTopic
, as there is no attempt to subscribe to an actual topic, but rather a request that when child topics are added below myTopic
the client is subscribed to them.
Note: You cannot get a notification for a subscription to a wildcard topic selector, as there are infinite possibilities matching the selector.