public RequestMessageRouter <IConsumeContext <TMessage>, TMessage> FindOrCreate <TMessage>() where TMessage : class { var configurator = new InboundMessageRouterConfigurator(_sink); MessageRouter <IConsumeContext <TMessage> > router = configurator.FindOrCreate <TMessage>(); var scope = new InboundRequestMessageRouterConfiguratorScope <TMessage>(); _sink.Inspect(scope); return(scope.Router ?? ConfigureRouter(router)); }
public CorrelatedMessageRouter <IConsumeContext <TMessage>, TMessage, TKey> FindOrCreate <TMessage, TKey>() where TMessage : class, ICorrelatedBy <TKey> { var configurator = new InboundMessageRouterConfigurator(_sink); MessageRouter <IConsumeContext <TMessage> > router = configurator.FindOrCreate <TMessage>(); var scope = new InboundCorrelatedMessageRouterConfiguratorScope <TMessage, TKey>(); _sink.Inspect(scope); return(scope.Router ?? ConfigureRouter <TMessage, TKey>(router)); }
public static UnsubscribeAction ConnectToRouter <TOutput>(this IInboundMessagePipeline pipeline, IPipelineSink <IConsumeContext <TOutput> > sink, Func <UnsubscribeAction> subscribedTo) where TOutput : class { var routerConfigurator = new InboundMessageRouterConfigurator(pipeline); MessageRouter <IConsumeContext <TOutput> > router = routerConfigurator.FindOrCreate <TOutput>(); UnsubscribeAction result = router.Connect(sink); UnsubscribeAction remove = subscribedTo(); return(() => result() && (router.SinkCount == 0) && remove()); }