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