Note that there are some explanatory texts on larger screens.

plurals
  1. POBus Configuration with Autofac: Issue with RabbitMQ vs Loopback?
    text
    copied!<p>For some reason I can not post to the <a href="https://groups.google.com/forum/?fromgroups#!forum/masstransit-discuss" rel="nofollow">masstransit google group</a>, even though I joined, I am told that I do not have permission to post to this group. So I am going to post here...</p> <p>Now for my problem:</p> <p>I am using MassTransit v2.7.2, with AutoFac v2.6.3. I am trying to configure Autofac to scan an assembly and register my consumers; all types that implement the IConsumer interface. This seems to work.</p> <p>I am using the MassTransit.AutofacIntegration assembly and the <code>LoadFrom(...)</code> extension method to register the consumers from the container with MassTransit when I configure the bus. Here is the code:</p> <pre><code>var builder = new ContainerBuilder(); builder .RegisterAssemblyTypes(typeof (CreateElectionCommandHandler).Assembly) .Where(type =&gt; type.Implements&lt;IConsumer&gt;()) .AsSelf(); var container = builder.Build(); var localBus = ServiceBusFactory.New(configurator =&gt; { //configurator.ReceiveFrom("loopback://localhost/testqueue"); configurator.ReceiveFrom("rabbitmq://localhost/commandqueue"); configurator.UseRabbitMq(); configurator.Subscribe(sbc =&gt; sbc.LoadFrom(container)); }); Assert.IsTrue(container.IsRegistered&lt;CreateElectionCommandHandler&gt;()); Assert.IsTrue(container.IsRegistered&lt;TerminateElectionCommandHandler&gt;()); Assert.AreEqual(1, localBus.HasSubscription&lt;CreateElection&gt;().Count()); Assert.AreEqual(1, localBus.HasSubscription&lt;TerminateElection&gt;().Count()); </code></pre> <p>If I run the above code using the loopback</p> <pre><code>configurator.ReceiveFrom("loopback://localhost/testqueue"); </code></pre> <p>configuration (comment out the rabbitmq conifig), the test will pass.</p> <p>If I comment out the "loopback" config and comment in the </p> <pre><code> configurator.ReceiveFrom("rabbitmq://localhost/commandqueue"); configurator.UseRabbitMq(); </code></pre> <p>config, the test will fail. (Note: The rabbitmq queue is already up and running - I have been using it as part of my POC). Specifically, it will fail on the assertion:</p> <pre><code>Assert.AreEqual(1, localBus.HasSubscription&lt;CreateElection&gt;().Count()); Assert.AreEqual(1, localBus.HasSubscription&lt;TerminateElection&gt;().Count()); </code></pre> <p>Can anybody help me understand what is going on here? I am new to MT so fully anticipating that I am missing something, or not configuring something correctly. </p> <p>Am I correct to assume that if there are no message subscriptions registered, then the bus will not be able to deliver to any of my consumers (even though the consumers are registered)?</p> <p>Any help much appreciated!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload