Search code examples
c#rabbitmqnservicebus

RabbitMQ error when setting up Learning Transport with NServiceBus


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.


Solution

  • 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