C# 使用NServiceBus设置学习传输时RabbitMQ错误

C# 使用NServiceBus设置学习传输时RabbitMQ错误,c#,rabbitmq,nservicebus,C#,Rabbitmq,Nservicebus,我已经成功地使用了NServiceBus的学习传输,同时构建了一个原型 然后,我向它添加了RabbitMQ支持,效果很好 当我(通过app.config)切换回学习传输时,即使未配置RabbitMQ,也会出现以下错误 System.Collections.Generic.KeyNotFoundException:字典中不存在给定的密钥(RabbitMQ.Routing TopologySupportsDelayedDelivery) 我的学习交通代码如下:- public Endpoin

我已经成功地使用了NServiceBus的学习传输,同时构建了一个原型

然后,我向它添加了RabbitMQ支持,效果很好

当我(通过app.config)切换回学习传输时,即使未配置RabbitMQ,也会出现以下错误

System.Collections.Generic.KeyNotFoundException:字典中不存在给定的密钥(RabbitMQ.Routing TopologySupportsDelayedDelivery)

我的学习交通代码如下:-

    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;
        }
    }
公共端点配置端点(ILog记录器、ServiceBusConfiguration配置)
{
尝试
{
//设置服务器端点
Debug($“正在创建服务器端点{config.ServerEndPointName}”);
var endpointConfiguration=newendpointconfiguration(config.ServerEndPointName);
Debug($“已创建服务器端点{config.ServerEndPointName}”);
Debug($“设置持久性”);
endpointConfiguration.UsePersistence();
Debug($“持久性设置”);
Debug($“设置传输”);
endpointConfiguration.UseTransport();
Debug($“传输设置”);
endpointConfiguration.EnableInstallers();
返回端点配置;
}
捕获(例外情况除外)
{
logger.Error($“无法配置服务端点。”,ex);
投掷;
}
}
我的RabbitMQ代码是

    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;
        }
    }
公共端点配置端点(ILog记录器、ServiceBusConfiguration配置)
{
尝试
{
//设置服务器端点
Debug($“正在创建服务器端点{config.ServerEndPointName}”);
var endpointConfiguration=newendpointconfiguration(config.ServerEndPointName);
Debug($“已创建服务器端点{config.ServerEndPointName}”);
Debug($“设置传输”);
var transport=endpointConfiguration.UseTransport();
//运输。使用常规路线拓扑();
transport.ConnectionString(config.RabbitMQConnectionString);
Debug($“传输设置”);
endpointConfiguration.EnableInstallers();
Debug($“设置持久性”);
endpointConfiguration.UsePersistence();
Debug($“持久性设置”);
返回端点配置;
}
捕获(例外情况除外)
{
logger.Error($“无法配置服务端点。”,ex);
投掷;
}
}
我正在使用NServiceBus v6.4.3和NServiceBus.RabbitMQ v4.4.1

有什么想法吗


我不明白为什么RabbitMQ会抱怨,当我配置为学习传输时甚至没有调用它。

简短回答:从扫描中排除RabbitMQ传输dll

例如:

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

详细回答:这种行为非常令人困惑,个人应该由NServiceBus团队解决。您观察到的问题是由引用RabbitMQ但未使用它的项目的程序集扫描引起的

在任何情况下,如果项目引用RabbitMQ传输而未将其选择为传输,则当前建议的解决方案是排除扫描


我们在

恶心下跟踪它,为什么在NSB中使用RMQ?前者我在使用的技术上没有选择。最有可能的是,未被引用的组件仍保留在bin文件夹中,NSB将对其进行扫描和提取。“修复”将是先进行清理,然后进行生成。最有可能的是,未引用的程序集仍保留在bin文件夹中,NSB将扫描并提取该文件夹。“修复”是先进行清理,然后进行构建。问题是传输可以通过配置进行切换,因此我无法从构建中删除dll。两者都需要携带。这就解决了问题。“问题是传输可以通过配置进行切换,所以我无法从构建中删除dll。”。介意再详细说明一下吗?为什么需要在同一端点中找到两个传输,并使用配置在两个传输之间切换?谢谢