Regular Expression Subscriptions

Regular Expression (Regex) subscriptions allow a regular expression to be supplied in the place of a topic name. When you supply a regular expression, it is as if a subscription is made to every topic that matches your expression, including topics that do not yet exist at the time of creating the subscription.

To use a regular expression, simply supply the regular expression in place of the topic name in the subscribe() call. For example:

Client c = ...;

foreach (Message msg in c.subscribe("client.*"))
{
   Console.WriteLine("{0}:{1}", msg.Topic, msg.Data);
}

In this example, messages on topics client and client1 would match the regular expression, and those messages would all be received by our subscription. As in the example, you can use the Topic property to determine the actual topic of the message sent to the lambda function.

Last updated