0
我与Nservicebus 4的RC2,并从以下位置下载PubSub的样品工作: http://particular.net/articles/windows-azure-transportNServiceBus 4基于代码的配置不工作
我试图做一个基于代码的配置(而不是如示例中所示的天蓝色csfg文件)。这适用于早期版本的NServiceBus,所以我不知道我在这里错过了什么。自定义配置未被拾取。这是一个错误?
下面是我做的改变应该重复的问题。
- 删除从webrole设置
- 在定制IConfigurationSource代替那些相同的配置设置的nservicebus配置和从总线引导代码除去AzureConfigurationSource。
这里是在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;
}
}
谢谢!这确实有效。然而,问题在于,这是以前的工作,所以我将需要改变我现有的端点使用这种方法,而不是IConfigurationSource。我会建议更改文档以表明这不是首选方法或将其标记为过时,因此用户不会碰到我所做的同一堵墙。大多数用户不会捕获(至少对于队列配置信誉),直到他们尝试超越本地模拟器,因为如您所知,默认连接是dev存储,并且使用自定义配置源似乎在本地工作,但不会。 – chutch
我会研究它! –
我刚刚发现ICustomconfigurationSource适用于使用天蓝色传输的控制台项目。所以这个问题似乎只适用于天蓝色的托管项目。为了测试这个,我引导了一个控制台项目作为一个客户端,并注册了一个AzureQueueConfig配置源,它工作。 – chutch