title: Out-of-order delivery acknowledgements in RabbitMQ
body: <p>In <em>manual-acknowledgement mode</em> (with <code>noAck=false</code>), messages may be acknowledged after being received and processed.  Using <code>IBasicConsumer</code>, the <a href="https://www.rabbitmq.com/dotnet-api-guide.html" rel="nofollow noreferrer">.NET/C# API Guide</a> suggests that this may be done, one-by-one, when a message is consumed:</p>
  
  <pre><code>var consumer = new EventingBasicConsumer(channel);
  
  consumer.Received += (_, e) =&gt; 
      {
          // process the message...
  
          channel.BasicAck(e.DeliveryTag, false);
      };
  
  string consumerTag = channel.BasicConsume(queueName, false, consumer);
  </code></pre>
  
  <p>In my particular scenario, however, I need to consume <strong>several</strong> messages before I'm able to process them. And, in order to retain durability, I would have to acknowledge previous messages only later on (outside the scope of when they were received). These acknowledgements might also happen in a <strong>different order</strong> from the order in which messages are received.</p>
  
  <pre><code>var consumer = new EventingBasicConsumer(channel);
  var buffer = new List&lt;BasicDeliverEventArgs&gt;();
  
  consumer.Received += (_, e) =&gt;
  {
      buffer.Add(e);
  
      if (TryProcess(buffer, out IList&lt;BasicDeliverEventArgs&gt; subset))
      {
          foreach (var p in subset)
          {
              channel.BasicAck(p.DeliveryTag, false);
              buffer.Remove(p);
          }
      }
  };
  
  string consumerTag = channel.BasicConsume(queueName, false, consumer);
  </code></pre>
  
  <p>When I try this I only receive a few messages and then something blocks, which leads me to thinking that RabbitMQ does not support this. I've also used the channel's <code>BasicQos</code> method to bump up the <code>prefetchCount</code> to hundreds, but the number of messages I receive is still only 4 or 5.</p>
  
  <p>Does RabbitMQ support out-of-order delivery acknowledgements? And if not, is there a better technique I can apply that uses RabbitMQ to provide the same durability?</p>