title: NodeJS + RabbitMQ - How to limit the number of messages a receiver processes
body: <p>I am using the amqplib node module and following the hello world send/receive tutorial.</p>
  
  <p><a href="https://github.com/squaremo/amqp.node/tree/master/examples/tutorials" rel="nofollow">https://github.com/squaremo/amqp.node/tree/master/examples/tutorials</a></p>
  
  <p>My receivers/workers take that message and perform a CPU intensive task in the background, so I can only process about 5 messages at once.</p>
  
  <p>What is the best way to control the number of messages that are being accepted by the receiver.</p>
  
  <p>Code sample:</p>
  
  <pre><code>var amqp = require('amqplib');
  
  amqp.connect('amqp://localhost').then(function(conn) {
      process.once('SIGINT', function() { conn.close(); });
      return conn.createChannel().then(function(ch) {
  
          var ok = ch.assertQueue('hello', {durable: false});
  
          ok = ok.then(function(_qok) {
              return ch.consume('hello', function(msg) {
                   console.log(" [x] Received '%s'", msg.content.toString());
              }, {noAck: true});
          });
  
              return ok.then(function(_consumeOk) {
              console.log(' [*] Waiting for messages. To exit press CTRL+C');
          });
      });
  }).then(null, console.warn);
  </code></pre>