title: MassTransit 2.6.1 Request/Response pattern - Response times out
body: <p>I'm looking at MassTransit as a ServiceBus implementation to use in a web project.</p>
  
  <p>I am playing with the <a href="http://docs.masstransit-project.com/en/latest/overview/request.html" rel="nofollow">Request/Response</a> pattern and am seeing a long delay between the consumer receiving the message and responding, and the request publisher handling the response; sometimes, it seems like the response is never going to come through (having left it running for 10 minutes, the response has still not come through). the only times that I have seen the handle delegate get called with the response is after a 30 second timeout period and the timeout exception being thrown; in this situation, the breakpoint set on the handler delegate is hit.</p>
  
  <p>The setup is a standard affair - I have a web app that is publishing requests, a console app that is consuming requests and sending responses, for the web app to handle the responses in the callback.</p>
  
  <p>I'm using Castle Windsor, and the container is initialized in the web project using WebActivator:</p>
  
  <pre><code>[assembly: WebActivator.PreApplicationStartMethod(typeof(BootStrapper), "PreStart")]
  [assembly: WebActivator.PostApplicationStartMethod(typeof(BootStrapper), "PostStart")]
  [assembly: WebActivator.ApplicationShutdownMethodAttribute(typeof(BootStrapper), "Stop")]
  
  namespace Web.App_Start
  {
      public static class BootStrapper
      {
          internal static IWindsorContainer Container { get; private set; }
  
          public static void PreStart()
          {
              Container = new WindsorContainer().Install(FromAssembly.This());
          }
  
          public static void PostStart()
          {
              FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
              RouteConfig.RegisterRoutes(RouteTable.Routes);
              BundleConfig.RegisterBundles(BundleTable.Bundles);
  
              ApiConfig.Configure(Container);
              MvcConfig.Configure(Container);
          }
  
          public static void Stop()
          {
              if (Container != null)
                  Container.Dispose();
          }
      }
  }
  </code></pre>
  
  <p><strong>In the web app project</strong> (an ASP.NET Web API project), the WindsorInstaller for MassTransit looks like</p>
  
  <pre><code>public class MassTransitInstaller : IWindsorInstaller
  {
      public void Install(IWindsorContainer container, IConfigurationStore store)
      {
          container.Register(AllTypes.FromThisAssembly().BasedOn&lt;IConsumer&gt;());
  
          var bus = ServiceBusFactory.New(configurator =&gt;
          {
              configurator.UseMsmq();
              configurator.VerifyMsmqConfiguration();            
              configurator.UseMulticastSubscriptionClient();
  
              configurator.ReceiveFrom("msmq://localhost/web");
  
              configurator.EnableMessageTracing();
              configurator.Subscribe(x =&gt; x.LoadFrom(container));
          });
  
          container.Register(Component.For&lt;IServiceBus&gt;().Instance(bus));
      }
  }
  </code></pre>
  
  <p><strong>In the console app project</strong>, the WindsorInstaller looks like</p>
  
  <pre><code>public class MassTransitInstaller : IWindsorInstaller
  {
      public void Install(IWindsorContainer container, IConfigurationStore store)
      {
          container.Register(AllTypes.FromAssemblyContaining&lt;BasicRequestCommandHandler&gt;().BasedOn&lt;IConsumer&gt;());
  
          var bus = ServiceBusFactory.New(configurator =&gt;
          {
              configurator.UseMsmq();
              configurator.VerifyMsmqConfiguration();
              configurator.UseMulticastSubscriptionClient();
  
              configurator.ReceiveFrom("msmq://localhost/console");
  
              configurator.Subscribe(x =&gt; x.LoadFrom(container));
          });
  
          container.Register(Component.For&lt;IServiceBus&gt;().Instance(bus));
      }
  }
  </code></pre>
  
  <p>I have an <code>ApiController</code> with the following GET action method</p>
  
  <pre><code>public class ExampleController : ApiController
  {
      private readonly IServiceBus _bus;
  
      public HelloController(IServiceBus bus)
      {
          _bus = bus;
      }
  
      // GET api/hello?text={some text}
      public Task&lt;IBasicResponseCommand&gt; Get(string text)
      {
          var command = new BasicRequestCommand {Text = text};
  
          var tcs = new TaskCompletionSource&lt;IBasicResponseCommand&gt;();
  
          _bus.PublishRequest(command, c =&gt;
          {
              c.Handle&lt;IBasicResponseCommand&gt;(r =&gt;
              {
                  tcs.SetResult(r);
              });
          });
  
          return tcs.Task;
      }
  }
  </code></pre>
  
  <p>BasicRequestCommand and BasicResponseCommand look like so</p>
  
  <pre><code>public interface IBasicRequestCommand
  {
      Guid CorrelationId { get; set; }
      string Text { get; set; }
  }
  
  public class BasicRequestCommand :
      CorrelatedBy&lt;Guid&gt;, IBasicRequestCommand
  {
      public Guid CorrelationId { get; set; }
      public string Text { get; set; }
  
      public BasicRequestCommand()
      {
          CorrelationId = Guid.NewGuid();
      }
  }
  
  public interface IBasicResponseCommand
  {
      Guid CorrelationId { get; set; }
      string Text { get; set; }
  }
  
  public class BasicResponseCommand :
      CorrelatedBy&lt;Guid&gt;, IBasicResponseCommand
  {
      public Guid CorrelationId { get; set; }
      public string Text { get; set; }
  }
  </code></pre>
  
  <p>And the handler responding to the BasicRequestCommand in the  console app:</p>
  
  <pre><code>public class BasicRequestCommandHandler : Consumes&lt;IBasicRequestCommand&gt;.Context
  {
      public void Consume(IConsumeContext&lt;IBasicRequestCommand&gt; context)
      {
          Console.Out.WriteLine("received message text " + context.Message.Text);
  
          context.Respond(new BasicResponseCommand { Text = "Hello " + context.Message.Text, CorrelationId = context.Message.CorrelationId });
      }
  }
  </code></pre>
  
  <p>I was anticipating with all of this running locally that the request/response would be in the order of a few seconds at most. Am I missing something in configuration? </p>
  
  <p>In addition, I wanted to hook MassTransit up to log4net. I am using Windsor's log4net logging facility and have a log4net section in web.config. This is all working fine for <code>ILogger</code> implementations provided by Windsor (and also for NHibernate logging), but it's <a href="http://docs.masstransit-project.com/en/latest/overview/logging.html" rel="nofollow">not clear from the documentation how to configure MassTransit to use this for logging</a>. Any ideas?</p>