Domanda

I'm using the Azure service bus topic in a publish/subscription pattern. I've got one topic and two subscriptions. One for the web site and one for a webjob. This works fine when only running one web site instance.

When Azure scales up to two instances the two webjob instances still use the same subscription so any single message is only handled by one of them which is exactly what I want.

But the same is true for the web sites which is not what I want. Both web site instances need to receive all messages and therefor need their own subscription.

Is there a way to get an "instance" name for the web sites and making the subscription dynamically (and remove the subscription again when the web site is scaled back)?

I could create a subscription called %HOSTNAME%-web or something similar. But how do I remove them afterwards when no longer needed?

È stato utile?

Soluzione

If you want all instances to receive a copy of the message, then as you state you will need to refactor so that each instance creates its own subscription.

To implement a "volatile" queue, look to the QueueDescription parameter " AutoDeleteOnIdle". http://msdn.microsoft.com/en-us/library/windowsazure/microsoft.servicebus.messaging.queuedescription.autodeleteonidle.aspx This should give you close to what you're looking for, just be careful to set the TimeSpan to a duration that will ensure you don't miss messages.

Alternative, if you only foresee scaling up to a few instances, you can just set the time to life on your messages appropriately and leave the queues in place to be reused the next time you "scale up" (although using a host name for this likely wouldn't be a good idea). Depending on message volume, the cost might be small compared to the cost of time required to develop an alternative approach.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top