title: RabbitMQ - Knowing Consumer is up
body: <p>I have a few questions on coding in RabbitMQ... I'm not new to this world and have got questions based on a design provided to me for implementation...</p>
  
  <ul>
  <li>If I send BasicAck or BasicAack from Consumer, does it only remove
  the corresponding message from the queue or will it deliver Ack to
  the Publisher?</li>
  <li>How do I ensure that Publisher sends message to Server only when Consumer is ready for processing?</li>
  </ul>
  
  <p>The design says Publisher needs to wait and know when the processing of Consumer is completed to do certain task on client side (depending on success / failure).</p>
  
  <p>I have tried below code but dequeue immediately removed message from queue without I send any Ack or Nack.  I'm confused</p>
  
  <p>publisher code:</p>
  
  <pre><code>using (var connection = factory.CreateConnection())
              {
                  using (var channel = connection.CreateModel())
                  {
                      channel.QueueDeclare("test", durable, false, false, null);
                      channel.TxSelect();
                      var properties = channel.CreateBasicProperties();
                      properties.SetPersistent(true);
  
                      string message = "Hello World!";
                      var body = Encoding.UTF8.GetBytes(message);
  
  
  
                      channel.BasicPublish("", "test", properties, body);
                      channel.TxCommit();
                      Console.WriteLine(" [x] Sent {0}", message);
                  }
              }
  </code></pre>
  
  <p>Consumer code</p>
  
  <pre><code> using (var connection = factory.CreateConnection())
          {
              using (var channel = connection.CreateModel())
              {
                  channel.QueueDeclare("test", durable, false, false, null);
  
                  var consumer = new QueueingBasicConsumer(channel);
                  channel.BasicConsume("test", true, consumer);
  
                  Console.WriteLine(" [*] Waiting for messages." +
                                           "To exit press CTRL+C");
                  while (true)
                  {
                      var ea = (BasicDeliverEventArgs)consumer.Queue.Dequeue();
  
                      var body = ea.Body;
                      var message = Encoding.UTF8.GetString(body);
                      Console.WriteLine(" [x] Received {0}", message);
                  }
              }
          }
  </code></pre>
  
  <p>Note: I realized that <code>channel.BasicConsume("test", true, consumer);</code> has noAck to true. I changed this to <code>channel.BasicConsume("test", false, consumer);</code>  </p>
  
  <p>I can see the message is removed from the queue when I used <code>channel.BasicAck(deliveryTag: ea.DeliveryTag, multiple: false);</code>  But, how does Publisher know that the Consumer processed it successfully?</p>