/// <summary> /// Registers a consumer given the lifetime scope specified /// </summary> /// <typeparam name="TConsumer">The consumer type</typeparam> /// <param name="configurator">The service bus configurator</param> /// <param name="scope">The LifetimeScope of the container</param> /// <param name="name">The name of the scope created per-message</param> /// <returns></returns> public static IConsumerSubscriptionConfigurator <TConsumer> Consumer <TConsumer>( this ISubscriptionBusServiceConfigurator configurator, ILifetimeScope scope, string name = "message") where TConsumer : class, IConsumer { var consumerFactory = new AutofacConsumerFactory <TConsumer>(scope, name); return(configurator.Consumer(consumerFactory)); }
public static IConsumerSubscriptionConfigurator <TConsumer> InterceptingConsumer <TConsumer>( [NotNull] this ISubscriptionBusServiceConfigurator configurator, [NotNull] IConsumerFactory <TConsumer> consumerFactory, [NotNull] Action <Action> interceptor) where TConsumer : class, IConsumer { if (_log.IsDebugEnabled) { _log.DebugFormat("Subscribing Intercepting Consumer: {0} (using supplied consumer factory)", typeof(TConsumer)); } var interceptingConsumerFactory = new InterceptingConsumerFactory <TConsumer>(consumerFactory, interceptor); return(configurator.Consumer(interceptingConsumerFactory)); }
public static IConsumerSubscriptionConfigurator <TConsumer> InterceptingConsumer <TConsumer>( [NotNull] this ISubscriptionBusServiceConfigurator configurator, [NotNull] Action <Action> interceptor) where TConsumer : class, IConsumer, new() { if (_log.IsDebugEnabled) { _log.DebugFormat("Subscribing Intercepting Consumer: {0} (using default consumer factory)", typeof(TConsumer)); } var delegateConsumerFactory = new DelegateConsumerFactory <TConsumer>(() => new TConsumer()); var interceptingConsumerFactory = new InterceptingConsumerFactory <TConsumer>(delegateConsumerFactory, interceptor); return(configurator.Consumer(interceptingConsumerFactory)); }
public void Configure <T>() where T : class, IConsumer { _configurator.Consumer(new AutofacConsumerFactory <T>(_scope, _name)); }