Note that there are some explanatory texts on larger screens.

plurals
  1. POAzure Service Bus broadcast to all worker role instances
    primarykey
    data
    text
    <p>I am trying to use to Azure Service Bus to broadcast a message from a Web Role to all the instances of a single worker role. This is the code I use to receive messages:</p> <pre><code>// Create the topic if it does not exist already string connectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString"); var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString); // Configure Topic Settings TopicDescription td = new TopicDescription("CommandTopic"); td.MaxSizeInMegabytes = 5120; td.DefaultMessageTimeToLive = new TimeSpan(0, 0, 1); if (!namespaceManager.TopicExists("CommandTopic")) { namespaceManager.CreateTopic(td); } Random rand = new Random(); double randNum = rand.Next(); if (!namespaceManager.SubscriptionExists("CommandTopic", "CommandSubscription"+randNum)) { namespaceManager.CreateSubscription("CommandTopic", "CommandSubscription" + randNum); } Client = SubscriptionClient.CreateFromConnectionString(connectionString, "CommandTopic", "CommandSubscription" + randNum, ReceiveMode.ReceiveAndDelete); Trace.WriteLine("SUBSCRIPTION: COMMANDSUBSCRIPTION"+randNum); </code></pre> <p>In order to create a separate subscription for each worker role instance (so that all instances receive the message in the topic) I had to use a random number. Is there a way of using some Id of the instance instead of the random number. There is Instance.Id however it is too long to be used as a parameter for the subscription name. Is there a shorter version without using substring? Also, is creating a separate subscription for each instance the proper approach? Previously all instances subscribed to the same subscription and so only 1 instance was getting the message and deleting it from the subscription.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload