Configure UniCastBus in NServiceBus using IWantToRunBeforeConfigurationIsFinalized

StackOverflow https://stackoverflow.com/questions/21735127

  •  10-10-2022
  •  | 
  •  

문제

I would like to "hook in" and tweak configuration to UnicastBus and was looking at doing this using IWantToRunBeforeConfigurationIsFinalized.

I would like to tweak/set the value for: ForwardReceivedMessagesTo. Any ideas on how that should be done?

도움이 되었습니까?

해결책

Unfortunately due to a bug (see https://github.com/Particular/NServiceBus/issues/1960), the only possible way is to programmatically replace the whole UnicastBusConfig, eg:

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

        return unicastBusConfig;
    }
}

But that is quite ugly :(

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top