我正在使用Nservicebus 4的RC2和从以下位置下载的PubSub示例: http://particular.net/articles/windows-azure-transport
我正在尝试进行基于代码的配置(而不是如示例中所示的azure csfg文件)。这适用于早期版本的NServiceBus,所以我不确定我在这里缺少什么。自定义配置未被选中。这是一个错误吗?
以下是我应该复制问题的更改。
以下是Global.asax.cs文件中更改的引导程序代码:
var bus = Configure.With()
.DefaultBuilder()
.CustomConfigurationSource(new CustomConfig())
.MessageForwardingInCaseOfFault()
.AzureMessageQueue()
.QueuePerInstance()
.UnicastBus()
.CreateBus()
.Start();
以下是CustomConfig类:
internal class CustomConfig : IConfigurationSource
{
public T GetConfiguration<T>() where T : class, new()
{
// the part you are overriding
if (typeof(T) == typeof(AzureQueueConfig))
return new AzureQueueConfig { ConnectionString = "storage key here", QueueName = "orderwebsiteinputqueue" } as T;
if (typeof(T) == typeof(MessageForwardingInCaseOfFaultConfig))
return new MessageForwardingInCaseOfFaultConfig { ErrorQueue = "errorqueue"} as T;
if (typeof(T) == typeof(TransportConfig))
return new TransportConfig() { MaxRetries = 5, MaximumConcurrencyLevel = 1} as T;
// leaving the rest of the configuration as is:
return ConfigurationManager.GetSection(typeof(T).Name) as T;
}
}
答案 0 :(得分:1)
自定义配置的推荐方法是实现IProvideConfiguration而不是替换配置源,你能试试吗?
亲切的问候, 伊夫