title: Azure Service Bus long running queue
body: <p>I am new to this and maybe i got the entire concept wrong, i wanted to have a permanently running background job in a container, which continously receives messages from an Azure Service Bus. There are going to be times when there will be no messages for more than an hour and there are going to be times when messages will come in flooding.</p>
  
  <p>I have set my bus up in Node.JS like below.</p>
  
  <p>Now when there are no messages for a certain amount of time the is going to resolve to an empty array as indicated by idleTimeoutInSeconds.
  Is the Azure Service Bus intended to be used to like i anticipated?
  If not is there something more fitting i can use to solve that?</p>
  
  <p>I would need something that runs permanently and reacts to new messages send.</p>
  
  <p>EDIT: A web server wouldnt necessary work in some scenarios, even though it would be a good fit.</p>
  
  <pre><code>async function main(){
    const sbClient = ServiceBusClient.createFromConnectionString(connectionString); 
    const queueClient = sbClient.createQueueClient(queueName);
    const receiver = queueClient.createReceiver(ReceiveMode.ReceiveAndDelete);
    try {
      while(true){
          const messages = await receiver..receiveMessages(10);
          console.log("Received messages:");
          console.log(messages.map(message =&gt; message.body));
          }
          } finally {
          await sbClient.close();
          }
  }
  
  main().catch((err) =&gt; {
    console.log("Error occurred: ", err);
  });
  </code></pre>