Azure Service Bus pub / sub for several azure web applications

I am trying to create a pub / sub with a service bus. I started with this tutorial and it has been working so far: https://azure.microsoft.com/en-gb/documentation/articles/service-bus-dotnet-how-to-use-topics-subscriptions/

But in my dedicated case, I don’t know exactly how I should do this:

I have an api web application running on an azure web application that scales to three instances. I have a console application client that runs some messages in a dedicated section.

What I want to achieve is that all three instances of the web api receive delivered messages that are sent to the message bus. Thus, this action preventing fire:

  • The client sends a message to the topic
  • Each subscriber who STRONGLY subscribes to this topic should receive a message

I am not interested in old messages that were sent when the subscriber was inactive / offline. I just synchronize the memory cache in these instances, so this is really short life information when I need to know which keys I must invalidate. but it is important that each subscriber receives information in order to avoid outdated data.

I'm not quite sure that I need to dynamically create a subscription in the web api startup code so that each instance has its own subscription or can I subscribe all instances of web applications to the same subscription? I would not want to create subscriptions dynamically, since I do not know when to delete them again (for example, reduced to two copies instead of three). but I could not find any documentation on how to do this, and if so, that several clients are subscribing to the same subscription or I need to create a subscription for each client.

+5
source share
1 answer

I'm not quite sure that I need to dynamically create a subscription in the web api startup code so that each instance has its own subscription or can I subscribe all instances of web applications to the same subscription?

Service Bus subscribers use the competing customer by default. You must create a unique subscription for each instance of the web API so that each instance can receive a copy of the message. This will be easiest when starting an instance of the web API.

I would not want to dynamically create subscriptions, since I do not know when to delete them again (for example, reduced to two copies instead of three).

You can set up an automatic deletion subscription after a period of inactivity. "Idle" in this case means that the web API instance has deployed and is no longer trying to receive messages in the subscription. When creating a subscription, set the topic time interval, set the value to DefaultMessageTimeToLive for a short time, for example. 5 seconds. This ensures that new subscribers will not see old messages.

+7
source

All Articles