azureservicebusazure-servicebus-topicsazure-servicebus-subscriptions

Azure ServiceBus wildcard subscription


I have two sets of agents running on a group of computers - they post to two services bus topics that were created on the azure portal:

I then have a server that needs to listen to any of these agents, from a namespace perspective announce/*

I have gone to create a subscription on my server via the azure portal, however i can only create a subscription to a specific topic i.e. announce/awoga-corp OR announce/company-first.

How can I with Azure subscrbe to receive all messages on master path (i.e announce/*) via single call with receiver.ReceiveMessageAsync(cancellationToken: stoppingToken)?

Sorry if some terminology is off, I am coming from an MQTT background.

subscription


Solution

  • In Azure Service Bus, a message must always be sent to a Topic. AFAIK, there is no concept of wildcard topic.

    You could create a single Topic (let's call it announce) and create two Subscriptions inside it (let's call them awoga-corp and company-first). Your agent would send the messages to the Topic and you can specify Filtering rules to send messages to these individual Subscriptions.

    If you wish to process all messages together, then all you would need to do is create a 3rd Subscription and set a Filtering rule so that all messages are also sent to this 3rd Subscription.

    You can then configure your receiver to receive messages from this 3rd Subscription only.