Example #1
0
        public bool Inspect <TMessage>(DistributorMessageSink <TMessage> sink)
            where TMessage : class
        {
            Append(string.Format("Distributor ({0})", GetMessageName <TMessage>()));

            return(true);
        }
        public UnsubscribeAction Connect(IInboundPipelineConfigurator configurator, IDistributor distributor)
        {
            IWorkerAvailability <TMessage> workerAvailability = distributor.GetWorkerAvailability <TMessage>();

            // TODO we need to make a saga worker availability so that we can split saga load by correlation id
            IWorkerSelector <TMessage> workerSelector = _workerSelectorFactory.GetSelector <TMessage>();

            var sink = new DistributorMessageSink <TMessage>(workerAvailability, workerSelector);

            return(configurator.Pipeline.ConnectToRouter(sink, () => configurator.SubscribedTo <TMessage>()));
        }
        protected virtual UnsubscribeAction ConnectDistributor <TComponent, TMessage>(ISubscriberContext context, Consumes <TMessage> .Selected consumer)
            where TComponent : Consumes <TMessage> .Selected
            where TMessage : class
        {
            var sink = new DistributorMessageSink <TMessage>(message =>
            {
                // rock it
                return(consumer.Accept(message) ? (Action <TMessage>)consumer.Consume : null);
            });

            return(context.Pipeline.ConnectToRouter(sink, () => context.SubscribedTo <TMessage>()));
        }
Example #4
0
        public UnsubscribeAction Connect(IInboundPipelineConfigurator configurator, object instance)
        {
            var distributor = instance as IDistributor <TMessage>;

            if (distributor == null)
            {
                throw new ConfigurationException("The connected instance is not a distributor");
            }

            var sink = new DistributorMessageSink <TMessage>(MultipleHandlerSelector.ForHandler(
                                                                 HandlerSelector.ForSelectiveHandler <TMessage>(distributor.Accept, distributor.Consume)));

            return(configurator.Pipeline.ConnectToRouter(sink, () => configurator.SubscribedTo <TMessage>()));
        }