title: MassTransit with RabbitMQ: MT timing out on second Request/Response
body: <p>Working with a Request/Response scenario with MassTransit and RabbitMQ. 
  When doing a simple Request/Reply it works multiple times. 
  If I publish a message in the request handler it  works on the first request, but the request handler never gets called on the second request and ends up timing out and the message stays in the Server Queue.</p>
  
  <p>It seems like I am missing something; configuration maybe?</p>
  
  <p>The project is at <a href="https://bitbucket.org/joeyoung/enterprise-rabbitmq" rel="nofollow">https://bitbucket.org/joeyoung/enterprise-rabbitmq</a></p>
  
  <p>The client configuration:</p>
  
  <pre><code>ObjectFactory.Configure(cfg =&gt;
  {
      cfg.AddRegistry&lt;WebRegistry&gt;();
      cfg.For&lt;IServiceBus&gt;().Singleton().Use(o =&gt; ServiceBusFactory.New(sbc =&gt;
      {
          // configure the bus
          sbc.UseRabbitMqRouting();
          sbc.ReceiveFrom("rabbitmq://localhost/entrprise_client");
  
          // finds all the consumers in the container and register them with the bus
          sbc.Subscribe(x =&gt; x.LoadFrom(ObjectFactory.Container));
      }));
  });
  </code></pre>
  
  <p>The Server Configuration:</p>
  
  <pre><code>var container = new Container(cfg =&gt;
  {
      cfg.Scan(scan =&gt;
      {
          scan.Assembly("Server.MessageHandlers");
          scan.AddAllTypesOf&lt;IConsumer&gt;();
      });
  });
  
  var bus = ServiceBusFactory.New(sbc =&gt;
  {
      // configure the bus
      sbc.UseRabbitMqRouting();
      sbc.ReceiveFrom("rabbitmq://localhost/enterprise_server");
  
      // finds all the consumers in the container and register them with the bus
      sbc.Subscribe(x =&gt; x.LoadFrom(container));
  });
  
  // finally inject the bus into the container
  container.Inject(bus);
  </code></pre>
  
  <p>Sending the Request:</p>
  
  <pre><code>bus.PublishRequest(new CreateProductCommand(correlationId, model.Name, model.Description, model.Price), x =&gt;
  {
      x.HandleTimeout(10.Seconds(), () =&gt; { timedOut = true; });
      x.Handle&lt;CreateProductCommand.Response&gt;(response =&gt; { productId = response.Id; });
  });
  </code></pre>
  
  <p>Consuming the Request:</p>
  
  <pre><code>public void Consume(IConsumeContext&lt;CreateProductCommand&gt; context)
  {
      Console.Out.WriteLine("Consuming Create Product");
  
      // simulate creating a product
      var productId = "products/1234";
  
      bus.Publish(new ProductCreatedEvent(productId));
  
      context.Respond(new CreateProductCommand.Response(context.Message.CorrelationId) { Id = productId});
  }
  </code></pre>
  
  <p>The Message:</p>
  
  <pre><code>public class CreateProductCommand : CorrelatedBy&lt;Guid&gt;
  {
      public Guid CorrelationId { get; private set; }
      public string Name { get; set; }
      public string Description { get; set; }
      public decimal Price { get; set; }
  
      public CreateProductCommand(Guid correlationId, string name, string description, decimal price) 
      {
          CorrelationId = correlationId;
          Name = name;
          Description = description;
          Price = price;
      }
  
      public class Response : CorrelatedBy&lt;Guid&gt;
      {
          public Guid CorrelationId { get; private set; }
  
          public string Id { get; set; }
  
          public Response(Guid correlationId)
          {
              CorrelationId = correlationId;
          }
      }
  }
  </code></pre>