Exemplo n.º 1
0
        public bool Inspect <TMessage>(WorkerMessageSink <TMessage> sink)
            where TMessage : class
        {
            Append(string.Format("Distributor Worker ({0})", typeof(TMessage).ToFriendlyName()));

            return(true);
        }
Exemplo n.º 2
0
        public bool Inspect <TMessage>(WorkerMessageSink <TMessage> sink) where TMessage : class
        {
            Type messageType = typeof(TMessage).GetGenericArguments().First();

            Append(string.Format("Distributor Worker ({0})", messageType.Name));

            return(true);
        }
        public UnsubscribeAction Connect(IInboundPipelineConfigurator configurator, IWorker worker)
        {
            IWorkerLoad <TMessage> workerLoad = worker.GetWorkerLoad <TMessage>();

            var consumerSink = new SelectedConsumerMessageSink <TConsumer, TMessage>(_consumerFactory);

            var sink = new WorkerMessageSink <TMessage>(workerLoad, consumerSink);

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

            return(context.Pipeline.ConnectToRouter(sink, () => context.SubscribedTo <Distributed <TMessage> >()));
        }
Exemplo n.º 5
0
        public UnsubscribeAction Connect(IInboundPipelineConfigurator configurator, IWorker worker)
        {
            IWorkerLoad <TMessage> workerLoad = worker.GetWorkerLoad <TMessage>();

            ISagaPolicy <TSaga, TMessage> policy = GetPolicy();

            ISagaMessageSink <TSaga, TMessage> messageSink = GetSagaMessageSink(_sagaRepository, policy);

            var sink = new WorkerMessageSink <TMessage>(workerLoad, messageSink);

            return(configurator.Pipeline.ConnectToRouter(sink, () => configurator.SubscribedTo <Distributed <TMessage> >()));
        }
        public ISubscriptionReference Connect(IInboundPipelineConfigurator configurator, IWorker worker)
        {
            IWorkerLoad <TMessage> workerLoad = worker.GetWorkerLoad <TMessage>();

            var handlerSink = new InstanceMessageSink <TMessage>(MultipleHandlerSelector.ForHandler(_handler));

            var sink = new WorkerMessageSink <TMessage>(workerLoad, handlerSink);

            UnsubscribeAction unsubscribeAction = configurator.Pipeline.ConnectToRouter(sink,
                                                                                        () => configurator.SubscribedTo <Distributed <TMessage> >());

            return(_referenceFactory(unsubscribeAction));
        }
        public UnsubscribeAction Connect(IInboundPipelineConfigurator configurator, object instance)
        {
            var worker = instance as IWorker <TMessage>;

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

            var sink = new WorkerMessageSink <Distributed <TMessage> >(MultipleHandlerSelector.ForHandler(
                                                                           HandlerSelector.ForSelectiveHandler <Distributed <TMessage> >(worker.Accept, worker.Consume)));

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