/// <summary> /// Connect a consumer with a consumer factory method /// </summary> /// <typeparam name="TConsumer"></typeparam> /// <typeparam name="TMessage"></typeparam> /// <param name="configurator"></param> /// <param name="context"></param> /// <param name="configure"></param> /// <returns></returns> public static void Consumer <TConsumer, TMessage>(this IBatchConfigurator <TMessage> configurator, IContext context, Action <IConsumerMessageConfigurator <TConsumer, Batch <TMessage> > > configure = null) where TConsumer : class, IConsumer <Batch <TMessage> > where TMessage : class { Consumer(configurator, context.GetInstance <IContainer>(), configure); }
/// <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); }
/// <summary> /// Connect a consumer with a consumer factory method /// </summary> /// <typeparam name="TConsumer"></typeparam> /// <typeparam name="TMessage"></typeparam> /// <param name="configurator"></param> /// <param name="context"></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, IComponentContext context, Action <IConsumerMessageConfigurator <TConsumer, Batch <TMessage> > > configure = null, string name = "message", Action <ContainerBuilder, ConsumeContext> configureScope = null) where TConsumer : class, IConsumer <Batch <TMessage> > where TMessage : class { Consumer(configurator, context.Resolve <ILifetimeScope>(), configure, name, configureScope); }
/// <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, IWindsorContainer container, Action <IConsumerMessageConfigurator <TConsumer, Batch <TMessage> > > configure = null) where TConsumer : class, IConsumer <Batch <TMessage> > where TMessage : class { RegisterScopedContextProviderIfNotPresent(container); Consumer(configurator, container.Kernel, configure); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }