コード例 #1
0
        public static HandlerWorkerConfigurator <T> Handler <T>(this WorkerBusServiceConfigurator configurator,
                                                                Action <IConsumeContext <T>, T> handler)
            where T : class
        {
            var handlerConfigurator = new HandlerWorkerConfiguratorImpl <T>(handler);

            configurator.AddConfigurator(handlerConfigurator);

            return(handlerConfigurator);
        }
コード例 #2
0
        static ConsumerWorkerConfigurator <TConsumer> CreateWorkerConsumerConfigurator <TConsumer>(
            WorkerBusServiceConfigurator configurator,
            IConsumerFactory <TConsumer> consumerFactory) where TConsumer : class, IConsumer
        {
            var consumerConfigurator = new ConsumerWorkerConfiguratorImpl <TConsumer>(consumerFactory);

            configurator.AddConfigurator(consumerConfigurator);

            return(consumerConfigurator);
        }
コード例 #3
0
        public static SagaWorkerConfigurator <TSaga> Saga <TSaga>(
            this WorkerBusServiceConfigurator configurator, ISagaRepository <TSaga> sagaRepository)
            where TSaga : class, ISaga
        {
            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("Subscribing Saga Worker: {0}", typeof(TSaga).ToShortTypeName());
            }

            var sagaConfigurator = new SagaWorkerConfiguratorImpl <TSaga>(sagaRepository);

            configurator.AddConfigurator(sagaConfigurator);

            return(sagaConfigurator);
        }
コード例 #4
0
        public static ConsumerWorkerConfigurator Consumer(
            [NotNull] this WorkerBusServiceConfigurator configurator,
            [NotNull] Type consumerType,
            [NotNull] Func <Type, object> consumerFactory)
        {
            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("Subscribing Consumer Worker: {0} (by type, using object consumer factory)",
                                 consumerType);
            }

            object consumerConfigurator =
                FastActivator.Create(typeof(UntypedConsumerWorkerConfigurator <>),
                                     new[] { consumerType }, new object[] { consumerFactory });

            configurator.AddConfigurator((WorkerBuilderConfigurator)consumerConfigurator);

            return((ConsumerWorkerConfigurator)consumerConfigurator);
        }