/// <summary> /// Registers a consumer given the lifetime scope specified /// </summary> /// <typeparam name="T">The consumer type</typeparam> /// <param name="configurator">The service bus configurator</param> /// <param name="kernel">The LifetimeScope of the container</param> /// <param name="configure"></param> /// <returns></returns> public static void Consumer <T>(this IReceiveEndpointConfigurator configurator, IKernel kernel, Action <IConsumerConfigurator <T> > configure = null) where T : class, IConsumer { IConsumerScopeProvider scopeProvider = new WindsorConsumerScopeProvider(kernel); var consumerFactory = new ScopeConsumerFactory <T>(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); }
public static void LoadFrom(this IReceiveEndpointConfigurator configurator, IKernel kernel) { if (configurator == null) { throw new ArgumentNullException(nameof(configurator)); } if (kernel == null) { throw new ArgumentNullException(nameof(kernel)); } IList <Type> consumerTypes = FindTypes <IConsumer>(kernel, x => !x.HasInterface <ISaga>()); if (consumerTypes.Count > 0) { var scopeProvider = new WindsorConsumerScopeProvider(kernel); foreach (var type in consumerTypes) { ConsumerConfiguratorCache.Configure(type, configurator, scopeProvider); } } IList <Type> sagaTypes = FindTypes <ISaga>(kernel, x => true); if (sagaTypes.Count > 0) { var repositoryFactory = new WindsorSagaRepositoryFactory(kernel); foreach (var sagaType in sagaTypes) { SagaConfiguratorCache.Configure(sagaType, configurator, repositoryFactory); } } }