使用 NServiceBus 设置 Learning Transport 时出现 RabbitMQ 错误
RabbitMQ error when setting up Learning Transport with NServiceBus
我在构建原型时成功地使用了 NServiceBus 的学习传输。
然后我添加了 RabbitMQ 支持,效果很好。
当我(通过 app.config)切换回学习传输时,即使没有配置 RabbitMQ,我也会收到以下错误
System.Collections.Generic.KeyNotFoundException: The given key (RabbitMQ.Routing TopologySupportsDelayedDelivery) was not present in the dictionary
我的学习传输代码如下:-
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;
}
}
我的 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;
}
}
我正在使用 NServiceBus v6.4.3 和 NServiceBus.RabbitMQ v4.4.1
有什么想法吗?
我不明白为什么 RabbitMQ 在配置为学习传输时甚至没有调用它时会抱怨。
简答:从扫描中排除 RabbitMQ 传输 dll。
https://docs.particular.net/nservicebus/hosting/assembly-scanning
示例:
scanner.ExcludeAssemblies("NServiceBus.Transports.RabbitMQ");
长答案:这种行为非常令人困惑,个人应该由 NServiceBus 团队修复
您观察到的问题是由于引用了RabbitMQ但没有使用它的项目的程序集扫描引起的。
在任何情况下,如果项目引用 RabbitMQ 传输而不选择它作为传输,则从扫描中排除是当前提出的解决方案。
我们在https://github.com/Particular/NServiceBus.RabbitMQ/issues/471
下跟踪它
我在构建原型时成功地使用了 NServiceBus 的学习传输。
然后我添加了 RabbitMQ 支持,效果很好。
当我(通过 app.config)切换回学习传输时,即使没有配置 RabbitMQ,我也会收到以下错误
System.Collections.Generic.KeyNotFoundException: The given key (RabbitMQ.Routing TopologySupportsDelayedDelivery) was not present in the dictionary
我的学习传输代码如下:-
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;
}
}
我的 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;
}
}
我正在使用 NServiceBus v6.4.3 和 NServiceBus.RabbitMQ v4.4.1
有什么想法吗?
我不明白为什么 RabbitMQ 在配置为学习传输时甚至没有调用它时会抱怨。
简答:从扫描中排除 RabbitMQ 传输 dll。
https://docs.particular.net/nservicebus/hosting/assembly-scanning
示例:
scanner.ExcludeAssemblies("NServiceBus.Transports.RabbitMQ");
长答案:这种行为非常令人困惑,个人应该由 NServiceBus 团队修复
您观察到的问题是由于引用了RabbitMQ但没有使用它的项目的程序集扫描引起的。
在任何情况下,如果项目引用 RabbitMQ 传输而不选择它作为传输,则从扫描中排除是当前提出的解决方案。
我们在https://github.com/Particular/NServiceBus.RabbitMQ/issues/471
下跟踪它