title: MassTransit Losing Messages - Rabbit MQ - When publisher and consumer endpoint names are the same,
body: <p>We've encountered a situation where MassTransit is losing messages if you create a publisher and consumer using the same endpoint name.</p>
  
  <p>Note the code below; if I use a different endpoint name for either the consumer or publisher (e.g. "rabbitmq://localhost/mtlossPublised" for the publisher) then the message counts both published and consumed match; if I use the same endpoint name (as in the sample) then I get less messages consumed than published.</p>
  
  <p>Is this expected behaviour? or am I doing something wrong, working sample code below.</p>
  
  <pre><code>using MassTransit;
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  
  namespace MTMessageLoss
  {
      class Program
      {
          static void Main(string[] args)
          {
              var consumerBus = ServiceBusFactory.New(b =&gt;
              {
                  b.UseRabbitMq();
                  b.UseRabbitMqRouting();
                  b.ReceiveFrom("rabbitmq://localhost/mtloss");
              });
              var publisherBus = ServiceBusFactory.New(b =&gt;
              {
                  b.UseRabbitMq();
                  b.UseRabbitMqRouting();
                  b.ReceiveFrom("rabbitmq://localhost/mtloss");
              });
              consumerBus.SubscribeConsumer(() =&gt; new MessageConsumer());
              for (int i = 0; i &lt; 10; i++)
                  publisherBus.Publish(new SimpleMessage() { CorrelationId = Guid.NewGuid(), Message = string.Format("This is message {0}", i) });
              Console.WriteLine("Press ENTER Key to see how many you consumed");
              Console.ReadLine();
              Console.WriteLine("We consumed {0} simple messages. Press Enter to terminate the applicaion.", MessageConsumer.Count);
              Console.ReadLine();
              consumerBus.Dispose();
              publisherBus.Dispose();
          }
      }
      public interface ISimpleMessage : CorrelatedBy&lt;Guid&gt;
      {
          string Message { get; }
      }
      public class SimpleMessage : ISimpleMessage
      {
          public Guid CorrelationId { get; set; }
          public string Message { get; set; }
      }
      public class MessageConsumer : Consumes&lt;ISimpleMessage&gt;.All
      {
          public static int Count = 0;
          public void Consume(ISimpleMessage message)
          {
              System.Threading.Interlocked.Increment(ref Count);
          }
      }
  }
  </code></pre>