使用IWantToRunBeforeConfigurationIsFinalized在NServiceBus中配置UniCastBus

时间:2014-02-12 17:26:50

标签: nservicebus

我想“挂钩”并将配置调整为UnicastBus,并且正在考虑使用IWantToRunBeforeConfigurationIsFinalized执行此操作。

我想调整/设置值ForwardReceivedMessagesTo。关于应该如何做的任何想法?

1 个答案:

答案 0 :(得分:0)

不幸的是,由于存在错误(请参阅https://github.com/Particular/NServiceBus/issues/1960),唯一可行的方法是以编程方式替换整个UnicastBusConfig,例如:

class Foo : IProvideConfiguration<UnicastBusConfig>
{
    public UnicastBusConfig GetConfiguration()
    {
        var unicastBusConfig = new UnicastBusConfig
        {
            ForwardReceivedMessagesTo = "FooBar",
        };
        unicastBusConfig.MessageEndpointMappings = new MessageEndpointMappingCollection();
        unicastBusConfig.MessageEndpointMappings.Add(...);

        return unicastBusConfig;
    }
}

但这很难看:(