コード例 #1
0
        /// <summary>
        /// Connect a consumer with a consumer factory method
        /// </summary>
        /// <typeparam name="TConsumer"></typeparam>
        /// <typeparam name="TMessage"></typeparam>
        /// <param name="configurator"></param>
        /// <param name="consumerFactory"></param>
        /// <returns></returns>
        public static void Consumer <TConsumer, TMessage>(this IBatchConfigurator <TMessage> configurator, IConsumerFactory <TConsumer> consumerFactory)
            where TConsumer : class, IConsumer <Batch <TMessage> >
            where TMessage : class
        {
            LogContext.Debug?.Log("Subscribing Batch Consumer: {ConsumerType} (using supplied consumer factory)", TypeMetadataCache <TConsumer> .ShortName);

            configurator.Consumer(consumerFactory);
        }
コード例 #2
0
        /// <summary>
        /// Connect a consumer with a consumer factory method
        /// </summary>
        /// <typeparam name="TConsumer"></typeparam>
        /// <typeparam name="TMessage"></typeparam>
        /// <param name="configurator"></param>
        /// <param name="consumerFactoryMethod"></param>
        /// <returns></returns>
        public static void Consumer <TConsumer, TMessage>(this IBatchConfigurator <TMessage> configurator, Func <TConsumer> consumerFactoryMethod)
            where TConsumer : class, IConsumer <Batch <TMessage> >
            where TMessage : class
        {
            LogContext.Debug?.Log("Subscribing Batch Consumer: {ConsumerType} (using delegate consumer factory)", TypeMetadataCache <TConsumer> .ShortName);

            var delegateConsumerFactory = new DelegateConsumerFactory <TConsumer>(consumerFactoryMethod);

            configurator.Consumer(delegateConsumerFactory);
        }
コード例 #3
0
        /// <summary>
        /// Connect a consumer with a consumer factory method
        /// </summary>
        /// <typeparam name="TConsumer"></typeparam>
        /// <typeparam name="TMessage"></typeparam>
        /// <param name="configurator"></param>
        /// <param name="container"></param>
        /// <param name="configure"></param>
        /// <returns></returns>
        public static void Consumer <TConsumer, TMessage>(this IBatchConfigurator <TMessage> configurator, IContainer container,
                                                          Action <IConsumerMessageConfigurator <TConsumer, Batch <TMessage> > > configure = null)
            where TConsumer : class, IConsumer <Batch <TMessage> >
            where TMessage : class
        {
            IConsumerScopeProvider scopeProvider = new StructureMapConsumerScopeProvider(container);

            IConsumerFactory <TConsumer> consumerFactory = new ScopeConsumerFactory <TConsumer>(scopeProvider);

            configurator.Consumer(consumerFactory, configure);
        }
コード例 #4
0
        /// <summary>
        /// Connect a consumer with a consumer factory method
        /// </summary>
        /// <typeparam name="TConsumer"></typeparam>
        /// <typeparam name="TMessage"></typeparam>
        /// <param name="configurator"></param>
        /// <param name="provider"></param>
        /// <param name="configure"></param>
        /// <returns></returns>
        public static void Consumer <TConsumer, TMessage>(this IBatchConfigurator <TMessage> configurator, IServiceProvider provider,
                                                          Action <IConsumerMessageConfigurator <TConsumer, Batch <TMessage> > > configure = null)
            where TConsumer : class, IConsumer <Batch <TMessage> >
            where TMessage : class
        {
            IConsumerScopeProvider scopeProvider = new DependencyInjectionConsumerScopeProvider(provider);

            IConsumerFactory <TConsumer> consumerFactory = new ScopeConsumerFactory <TConsumer>(scopeProvider);

            configurator.Consumer(consumerFactory, configure);
        }
コード例 #5
0
        /// <summary>
        /// Connect a consumer with a consumer factory method
        /// </summary>
        /// <typeparam name="TConsumer"></typeparam>
        /// <typeparam name="TMessage"></typeparam>
        /// <param name="configurator"></param>
        /// <param name="kernel"></param>
        /// <param name="configure"></param>
        /// <returns></returns>
        public static void Consumer <TConsumer, TMessage>(this IBatchConfigurator <TMessage> configurator, IKernel kernel,
                                                          Action <IConsumerMessageConfigurator <TConsumer, Batch <TMessage> > > configure = null)
            where TConsumer : class, IConsumer <Batch <TMessage> >
            where TMessage : class
        {
            IConsumerScopeProvider scopeProvider = new WindsorConsumerScopeProvider(kernel);

            IConsumerFactory <TConsumer> consumerFactory = new ScopeConsumerFactory <TConsumer>(scopeProvider);

            configurator.Consumer(consumerFactory, configure);
        }
コード例 #6
0
        /// <summary>
        /// Connect a consumer with a consumer factory method
        /// </summary>
        /// <typeparam name="TConsumer"></typeparam>
        /// <typeparam name="TMessage"></typeparam>
        /// <param name="configurator"></param>
        /// <param name="scope"></param>
        /// <param name="configure"></param>
        /// <param name="name">The name of the scope created per-message</param>
        /// <param name="configureScope">Configuration for scope container</param>
        /// <returns></returns>
        public static void Consumer <TConsumer, TMessage>(this IBatchConfigurator <TMessage> configurator, ILifetimeScope scope,
                                                          Action <IConsumerMessageConfigurator <TConsumer, Batch <TMessage> > > configure = null, string name = "message",
                                                          Action <ContainerBuilder, ConsumeContext> configureScope = null)
            where TConsumer : class, IConsumer <Batch <TMessage> >
            where TMessage : class
        {
            IConsumerScopeProvider scopeProvider = new AutofacConsumerScopeProvider(new SingleLifetimeScopeProvider(scope), name, configureScope);

            IConsumerFactory <TConsumer> consumerFactory = new ScopeConsumerFactory <TConsumer>(scopeProvider);

            configurator.Consumer(consumerFactory, configure);
        }
コード例 #7
0
        /// <summary>
        /// Connect a consumer with a consumer factory method
        /// </summary>
        /// <typeparam name="TConsumer"></typeparam>
        /// <typeparam name="TMessage"></typeparam>
        /// <param name="configurator"></param>
        /// <param name="consumerFactoryMethod"></param>
        /// <returns></returns>
        public static void Consumer <TConsumer, TMessage>(this IBatchConfigurator <TMessage> configurator, Func <TConsumer> consumerFactoryMethod)
            where TConsumer : class, IConsumer <Batch <TMessage> >
            where TMessage : class
        {
            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("Subscribing Consumer: {0} (using delegate consumer factory)", TypeMetadataCache <TConsumer> .ShortName);
            }

            var delegateConsumerFactory = new DelegateConsumerFactory <TConsumer>(consumerFactoryMethod);

            configurator.Consumer(delegateConsumerFactory);
        }