public UnsubscribeAction Connect(IInboundPipelineConfigurator configurator, string requestId,
                                         HandlerSelector <TMessage> handler)
        {
            if (handler == null)
            {
                throw new ArgumentNullException("handler", "The handler cannot be null.");
            }

            var correlatedConfigurator = new InboundRequestMessageRouterConfigurator(configurator.Pipeline);

            RequestMessageRouter <IConsumeContext <TMessage>, TMessage> router =
                correlatedConfigurator.FindOrCreate <TMessage>();

            var sink = new InstanceMessageSink <TMessage>(MultipleHandlerSelector.ForHandler(handler));

            UnsubscribeAction result = router.Connect(requestId, sink);

            return(() => result() && (router.SinkCount(requestId) == 0)); // && remove();
        }
예제 #2
0
        public UnsubscribeAction Connect(IInboundPipelineConfigurator configurator, string requestId, HandlerSelector <TMessage> handler)
        {
            if (handler == null)
            {
                throw new NullReferenceException("The handler cannot be null.");
            }

            var correlatedConfigurator = new InboundRequestMessageRouterConfigurator(configurator.Pipeline);

            RequestMessageRouter <IConsumeContext <TMessage>, TMessage> router =
                correlatedConfigurator.FindOrCreate <TMessage>();

            var sink = new InstanceMessageSink <TMessage>(MultipleHandlerSelector.ForHandler(handler));

            UnsubscribeAction result = router.Connect(requestId, sink);

            // TODO this should NOT publish a correlated subscription, in fact, do we even need to subscribe?
            //UnsubscribeAction remove = configurator.SubscribedTo<TMessage>();

            return(() => result() && (router.SinkCount(requestId) == 0));// && remove();
        }