public static IInstanceSubscriptionConfigurator Instance( [NotNull] this ISubscriptionBusServiceConfigurator configurator, [NotNull] object instance) { var instanceConfigurator = new InstanceSubscriptionConfigurator(instance); var busServiceConfigurator = new SubscriptionBusServiceBuilderConfigurator(instanceConfigurator); configurator.AddConfigurator(busServiceConfigurator); return(instanceConfigurator); }
public static IHandlerSubscriptionConfigurator <T> Handler <T>(this ISubscriptionBusServiceConfigurator configurator, Action <IConsumeContext <T>, T> handler) where T : class { var handlerConfigurator = new HandlerSubscriptionConfigurator <T>(handler); var busServiceConfigurator = new SubscriptionBusServiceBuilderConfigurator(handlerConfigurator); configurator.AddConfigurator(busServiceConfigurator); return(handlerConfigurator); }
/// <summary> /// Configure a saga subscription /// </summary> /// <typeparam name="TSaga"></typeparam> /// <param name="configurator"></param> /// <param name="sagaRepository"></param> /// <returns></returns> public static ISagaSubscriptionConfigurator <TSaga> Saga <TSaga>( this ISubscriptionBusServiceConfigurator configurator, ISagaRepository <TSaga> sagaRepository) where TSaga : class, ISaga { if (_log.IsDebugEnabled) { _log.DebugFormat("Subscribing Saga: {0}", typeof(TSaga)); } var sagaConfigurator = new SagaSubscriptionConfigurator <TSaga>(sagaRepository); var busServiceConfigurator = new SubscriptionBusServiceBuilderConfigurator(sagaConfigurator); configurator.AddConfigurator(busServiceConfigurator); return(sagaConfigurator); }
public static IConsumerSubscriptionConfigurator <TConsumer> Consumer <TConsumer>( [NotNull] this ISubscriptionBusServiceConfigurator configurator, [NotNull] IConsumerFactory <TConsumer> consumerFactory) where TConsumer : class, IConsumer { if (_log.IsDebugEnabled) { _log.DebugFormat("Subscribing Consumer: {0} (using supplied consumer factory)", typeof(TConsumer)); } var consumerConfigurator = new ConsumerSubscriptionConfigurator <TConsumer>(consumerFactory); var busServiceConfigurator = new SubscriptionBusServiceBuilderConfigurator(consumerConfigurator); configurator.AddConfigurator(busServiceConfigurator); return(consumerConfigurator); }
public static IConsumerSubscriptionConfigurator <TConsumer> Consumer <TConsumer>( [NotNull] this ISubscriptionBusServiceConfigurator configurator) where TConsumer : class, IConsumer, new() { if (_log.IsDebugEnabled) { _log.DebugFormat("Subscribing Consumer: {0} (using default consumer factory)", typeof(TConsumer)); } var delegateConsumerFactory = new DelegateConsumerFactory <TConsumer>(() => new TConsumer()); var consumerConfigurator = new ConsumerSubscriptionConfigurator <TConsumer>(delegateConsumerFactory); var busServiceConfigurator = new SubscriptionBusServiceBuilderConfigurator(consumerConfigurator); configurator.AddConfigurator(busServiceConfigurator); return(consumerConfigurator); }
public static IConsumerSubscriptionConfigurator Consumer( [NotNull] this ISubscriptionBusServiceConfigurator configurator, [NotNull] Type consumerType, [NotNull] Func <Type, object> consumerFactory) { if (_log.IsDebugEnabled) { _log.DebugFormat("Subscribing Consumer: {0} (by type, using object consumer factory)", consumerType); } var consumerConfigurator = (ISubscriptionBuilderConfigurator) FastActivator.Create(typeof(UntypedConsumerSubscriptionConfigurator <>), new[] { consumerType }, new object[] { consumerFactory }); var busServiceConfigurator = new SubscriptionBusServiceBuilderConfigurator(consumerConfigurator); configurator.AddConfigurator(busServiceConfigurator); return(consumerConfigurator as IConsumerSubscriptionConfigurator); }