1. Themes
Themes are a publishing / distribution mechanism that will send a message once per subscription (subscriber).
Subscribing to a topic is like a virtual queue that receives copies of messages sent to a topic. Messages are received from the subscription identically to how they are received from the queue ...
Subscriptions support the same patterns that were described earlier in this section regarding queues: a competing customer, temporary isolation, load balancing, and load balancing.
Source: MSDN Article
To achieve your scenario, you need to reuse topic subscriptions among competing consumers (service instances).
Publisher #1 ββββ ββββ Subscription 1 ββββ¦βββ Service 1-instance 1 β β ββββ Service 1-instance 2 β βββ Topic ββββ£ β β ββββ Service 2-instance 1 Publisher #2 ββββ ββββ Subscription 2 ββββ©βββ Service 2-instance 2
A. Create a topic subscription
string connectionString = "<Secret>" var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString); if (!namespaceManager.SubscriptionExists("TestTopic", "Inventory")) { namespaceManager.CreateSubscription("TestTopic", "Inventory"); }
B. Listen to an existing subscription
MessagingFactory factory = MessagingFactory.Create(uri, tokenProvider); MessageReceiver receiver = factory.CreateMessageReceiver("TestTopic/subscriptions/Inventory");
2. Queues
Using multiple Queues may also be appropriate for your specific scenario. Each Queue , having several competing consumers (instances), delivers the message only once to the first client, who requests and processes it successfully.
Then the design becomes:
Publisher #1 ββββ ββββ Service 1 Queue ββββ¦βββ Subscriber #1 (Service 1) β β ββββ Subscriber #2 (Service 1) β βββASBββββ£ β β ββββ Subscriber #3 (Service 2) Publisher #2 ββββ ββββ Service 2 Queue ββββ©βββ Subscriber #4 (Service 2)
source share