public void Configure(RouterConfiguration routerConfig) { var settings = routerConfig.Settings.Get <DeduplicationSettings>(); var inboxDestinationKey = routerConfig.Name; var outboxSourceKey = routerConfig.Name; var inboxInstaller = new InboxInstaller(inboxDestinationKey); var inboxPersisterCollection = new InboxPersisterCollection(inboxDestinationKey, settings); var outboxInstaller = new OutboxInstaller(outboxSourceKey); var outboxPersisterCollection = new OutboxPersisterCollection(outboxSourceKey, settings); var dispatcher = new Dispatcher(settings); if (settings.RunInstaller) { routerConfig.AddModule(new Installer(settings, outboxInstaller, inboxInstaller)); } routerConfig.AddModule(dispatcher); routerConfig.AddModule(outboxPersisterCollection); routerConfig.AddModule(inboxPersisterCollection); routerConfig.AddRule(_ => new CaptureOutgoingMessageRule(settings)); routerConfig.AddRule(_ => new OutboxRule(outboxPersisterCollection, dispatcher)); routerConfig.AddRule(_ => new InboxRule(inboxPersisterCollection, settings)); }
/// <summary> /// Adds a global (applicable to all interfaces) routing rule. /// </summary> /// <typeparam name="TRule">Type of the rule.</typeparam> /// <param name="constructor">Delegate that constructs a new instance of the rule.</param> /// <param name="condition">Condition which must be true for the rule to be added to the chain.</param> public void AddRule <TRule>(Func <IRuleCreationContext, TRule> constructor, Func <IRuleCreationContext, bool> condition = null) where TRule : IRule { RouterConfiguration.AddRule(constructor, context => { if (condition == null) { return(context.InterfaceName == Name); } return(condition(context) && context.InterfaceName == Name); }); }