title: Azure Service Bus messages not being received
body: <p>I am sending a message from web role to worker role. Earlier these messages were received properly and instantly but now out of nowhere some messages are not being received, even though the content of all messages are same. Like if i send one message now, its not received but immediately after that if i send another then the latest one is received. The one which was not received earlier, suddenly gets received after a few seconds or sometimes goes into dead letter messages as the time to live has expired.</p>
  
  <p>I am not able to figure out what the problem can be, any ideas? or is this behaviour normal with service bus?</p>
  
  <p>This is how am receiving the message in worker role</p>
  
  <p>EDIT:</p>
  
  <pre><code>public override void Run()
      {
          while (!IsStopped)
          {
              try
              {
                  if (BroadcastReceived)
                  {
                      BroadcastReceived = false;
                      // Receive the message from Web Role to upload the broadcast to queue
                      BroadcastClient.BeginReceive(OnWebRoleMessageReceived, null);
                  }
  
                  if (SignalRMessageReceived)
                  {
                      SignalRMessageReceived = false;
                      // Receive the message from SignalR BroadcastHub
                      SignalRClient.BeginReceive(OnSignalRMessageReceived, null);
                  }
  
                  if (SignalRFirstTimeMessageReceived)
                  {
                      SignalRFirstTimeMessageReceived = false;
                      // Receive the message from SignalR BroadcastHub
                      SignalRFirstTimeClient.BeginReceive(OnSignalRFirstTimeMessageReceived, null);
                  }          
           }
       }
  
  
  public void OnWebRoleMessageReceived(IAsyncResult iar)
      {
          BrokeredMessage receivedBroadcastMessage = null;
          receivedBroadcastMessage = BroadcastClient.EndReceive(iar);
  
          if (receivedBroadcastMessage != null)
          {
              // Process the message
             receivedBroadcastMessage.Complete();
          }
  BroadcastReceived = true;
       }
  </code></pre>
  
  <p>UPDATE :</p>
  
  <pre><code>BroadcastClient = CloudStorageHelper.GetServiceBusQueueClient(Queuenames.ApiToWorkerRole);
  
  public static QueueClient GetServiceBusQueueClient(string queuename)
      {
          string connectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");
  
          var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
  
          if (!namespaceManager.QueueExists(queuename))
          {
              namespaceManager.CreateQueue(queuename);
          }
  
          QueueClient Client = QueueClient.CreateFromConnectionString(connectionString, queuename);
  
  
  
          return Client;
      }
  </code></pre>
  
  <p>Web Role:</p>
  
  <pre><code>var queueClient = CloudStorageHelper.GetServiceBusQueueClient(Queuenames.ApiToWorkerRole);
  
              //for testing purposes
              record.Username = "owner";
              record.Channel = "World";
              record.Title = "Sample";
              record.Duration = 10;
  
              BrokeredMessage message = new BrokeredMessage(record);
  
              queueClient.Send(message);
  </code></pre>