0

I have been using the learning transport with NServiceBus successfully whilst building a prototype.

I have then added RabbitMQ support to it which works fine.

When I switch (via app.config) back to learning transport, I get the following error even though RabbitMQ is not being configured

System.Collections.Generic.KeyNotFoundException: The given key (RabbitMQ.Routing TopologySupportsDelayedDelivery) was not present in the dictionary

My learning transport code is as follows :-

    public EndpointConfiguration ConfigureEndPoint(ILog logger, ServiceBusConfiguration config)
    {
        try
        {
            // set up server endpoint
            logger.Debug($"Creating server endpoint {config.ServerEndPointName}.");
            var endpointConfiguration = new EndpointConfiguration(config.ServerEndPointName);
            logger.Debug($"Server endpoint {config.ServerEndPointName} created.");
            logger.Debug($"Setting up persistence.");
            endpointConfiguration.UsePersistence<LearningPersistence>();
            logger.Debug($"Persistence set up.");
            logger.Debug($"Setting up transport.");
            endpointConfiguration.UseTransport<LearningTransport>();
            logger.Debug($"Transport set up.");

            endpointConfiguration.EnableInstallers();
            return endpointConfiguration;
        }
        catch (Exception ex)
        {
            logger.Error($"Could not configure service endpoint.", ex);
            throw;
        }
    }

My RabbitMQ code is

    public EndpointConfiguration ConfigureEndPoint(ILog logger, ServiceBusConfiguration config)
    {
        try
        {
            // set up server endpoint
            logger.Debug($"Creating server endpoint {config.ServerEndPointName}.");
            var endpointConfiguration = new EndpointConfiguration(config.ServerEndPointName);
            logger.Debug($"Server endpoint {config.ServerEndPointName} created.");
            logger.Debug($"Setting up transport.");
            var transport = endpointConfiguration.UseTransport<RabbitMQTransport>();
            //transport.UseConventionalRoutingTopology();
            transport.ConnectionString(config.RabbitMQConnectionString);
            logger.Debug($"Transport set up.");

            endpointConfiguration.EnableInstallers();

            logger.Debug($"Setting up persistence.");
            endpointConfiguration.UsePersistence<InMemoryPersistence>();
            logger.Debug($"Persistence set up.");
            return endpointConfiguration;
        }
        catch (Exception ex)
        {
            logger.Error($"Could not configure service endpoint.", ex);
            throw;
        }
    }

I am using NServiceBus v6.4.3 and NServiceBus.RabbitMQ v4.4.1

Any ideas?

I can't figure out why RabbitMQ is complaining when I am not even invoking it when configured for learning transport.

Ace Grace
  • 631
  • 1
  • 7
  • 21
  • Yuck, why use RMQ with NSB? The former _[doesn't even have message retry](https://stackoverflow.com/a/23161921/585968)_ –  Jan 30 '18 at 10:55
  • I don't have a choice in the technology used. – Ace Grace Jan 30 '18 at 11:32
  • Most likely, the assembly that's not referenced has remained in the bin folder, which will get scanned and picked up by NSB. The 'fix' would be to do a Clean and then build. – Hadi Eskandari Jan 31 '18 at 07:28

2 Answers2

2

Short answer: exclude RabbitMQ transport dll from scanning.

https://docs.particular.net/nservicebus/hosting/assembly-scanning

Example:

scanner.ExcludeAssemblies("NServiceBus.Transports.RabbitMQ");

Long answer: such behavior is very confusing and personally should be fixed by NServiceBus team

alex.dev
  • 170
  • 11
  • Most likely, the assembly that's not referenced has remained in the bin folder, which will get scanned and picked up by NSB. The 'fix' would be to do a Clean and then build. – Hadi Eskandari Jan 31 '18 at 07:28
  • 1
    The trouble is that the transport can be switched via configuration so I can't remove the dll from the build. Both need to be carried. – Ace Grace Jan 31 '18 at 09:25
  • That gets around the problem. – Ace Grace Jan 31 '18 at 14:13
  • _"The trouble is that the transport can be switched via configuration so I can't remove the dll from the build"_. Mind to expand on that? Why do you need both transport to be found in the same endpoint and switch between the two using configuration? Thanks. – Sean Feldman Jan 31 '18 at 15:46
0

The problem that you observe is caused by the assembly scanning of a project that references RabbitMQ but does not use it.

In any case, where a project references RabbitMQ transport without selecting it as a transport, the exclusion from scanning is the currently proposed solution.

We track it under https://github.com/Particular/NServiceBus.RabbitMQ/issues/471

Scooletz
  • 183
  • 2
  • 7