title: How to handle Publish Confirm in RabbitMQ .NET
body: <p>I'm new in RabbitMQ. i need to know how to Publish Confirm in .NET because i need to send and receive response from client/server. The problem is i dont know how to correctly handle publish Confirm.</p>
  
  <pre><code> channel.ConfirmSelect();
   var outstandingConfirms = new ConcurrentDictionary&lt;ulong, string&gt;();
  
              void cleanOutstandingConfirms(ulong sequenceNumber, bool multiple)
              {
                  if (multiple)
                  {
                      var confirmed = outstandingConfirms.Where(k =&gt; k.Key &lt;= sequenceNumber);
                      foreach (var entry in confirmed)
                          outstandingConfirms.TryRemove(entry.Key, out _);
                  }
                  else
                      outstandingConfirms.TryRemove(sequenceNumber, out _);
              }
  
              channel.BasicAcks += (sender, ea) =&gt; cleanOutstandingConfirms(ea.DeliveryTag, ea.Multiple);
              channel.BasicNacks += (sender, ea) =&gt;
              {
                  outstandingConfirms.TryGetValue(ea.DeliveryTag, out string body);
                  Console.WriteLine($"Message with body {body} has been nack-ed. Sequence number: {ea.DeliveryTag}, multiple: {ea.Multiple}");
                  cleanOutstandingConfirms(ea.DeliveryTag, ea.Multiple);
              };
  
              for (int i = 0; i &lt; MESSAGE_COUNT; i++)
              {
                  var body = i.ToString();
                  outstandingConfirms.TryAdd(channel.NextPublishSeqNo, i.ToString());
                  channel.BasicPublish("",
                  routingKey: "****",
                  basicProperties: null,
                  body: Encoding.UTF8.GetBytes(body)); 
              }
  </code></pre>
  
  <p>I need to receive response from client server after message already arrived.
  like "Success Add Data"</p>
  
  <p>i get this from the rabbitmq documentation(Handling Publisher Confirms Asynchronously). But i dont know how it is work. Im welcome for disscuss and learn from you guys. Correct me if im wrong please, Thank you</p>