public static HandlerSubscriptionConfigurator <T> Handler <T>(this SubscriptionBusServiceConfigurator configurator, Action <IConsumeContext <T>, T> handler) where T : class { var handlerConfigurator = new HandlerSubscriptionConfiguratorImpl <T>(handler); var busServiceConfigurator = new SubscriptionBusServiceBuilderConfiguratorImpl(handlerConfigurator); configurator.AddConfigurator(busServiceConfigurator); return(handlerConfigurator); }
/// <summary> /// Subscribes an object instance to the bus /// </summary> /// <param name="configurator"></param> /// <param name="instance"></param> /// <returns></returns> public static InstanceSubscriptionConfigurator Instance( [NotNull] this SubscriptionBusServiceConfigurator configurator, [NotNull] object instance) { var instanceConfigurator = new InstanceSubscriptionConfiguratorImpl(instance); var busServiceConfigurator = new SubscriptionBusServiceBuilderConfiguratorImpl(instanceConfigurator); configurator.AddConfigurator(busServiceConfigurator); return(instanceConfigurator); }
/// <summary> /// Configure a saga subscription /// </summary> /// <typeparam name="TSaga"></typeparam> /// <param name="configurator"></param> /// <param name="sagaRepository"></param> /// <returns></returns> public static SagaSubscriptionConfigurator <TSaga> Saga <TSaga>( this SubscriptionBusServiceConfigurator configurator, ISagaRepository <TSaga> sagaRepository) where TSaga : class, ISaga { if (_log.IsDebugEnabled) { _log.DebugFormat("Subscribing Saga: {0}", typeof(TSaga)); } var sagaConfigurator = new SagaSubscriptionConfiguratorImpl <TSaga>(sagaRepository); var busServiceConfigurator = new SubscriptionBusServiceBuilderConfiguratorImpl(sagaConfigurator); configurator.AddConfigurator(busServiceConfigurator); return(sagaConfigurator); }
public static ConsumerSubscriptionConfigurator <TConsumer> Consumer <TConsumer>( [NotNull] this SubscriptionBusServiceConfigurator configurator, [NotNull] IConsumerFactory <TConsumer> consumerFactory) where TConsumer : class { if (_log.IsDebugEnabled) { _log.DebugFormat("Subscribing Consumer: {0} (using supplied consumer factory)", typeof(TConsumer)); } var consumerConfigurator = new ConsumerSubscriptionConfiguratorImpl <TConsumer>(consumerFactory); var busServiceConfigurator = new SubscriptionBusServiceBuilderConfiguratorImpl(consumerConfigurator); configurator.AddConfigurator(busServiceConfigurator); return(consumerConfigurator); }
public static ConsumerSubscriptionConfigurator <TConsumer> Consumer <TConsumer>( [NotNull] this SubscriptionBusServiceConfigurator configurator) where TConsumer : class, 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 ConsumerSubscriptionConfiguratorImpl <TConsumer>(delegateConsumerFactory); var busServiceConfigurator = new SubscriptionBusServiceBuilderConfiguratorImpl(consumerConfigurator); configurator.AddConfigurator(busServiceConfigurator); return(consumerConfigurator); }
public static StateMachineSubscriptionConfigurator <TInstance> StateMachineSaga <TInstance>( this SubscriptionBusServiceConfigurator configurator, StateMachine <TInstance> stateMachine, ISagaRepository <TInstance> sagaRepository) where TInstance : class, SagaStateMachineInstance { var stateMachineSagaRepositoryConfigurator = new StateMachineSagaRepositoryConfiguratorImpl <TInstance>(stateMachine, sagaRepository); StateMachineSagaRepository <TInstance> repository = stateMachineSagaRepositoryConfigurator.Configure(); var stateMachineConfigurator = new StateMachineSubscriptionConfiguratorImpl <TInstance>(stateMachine, repository); var busServiceConfigurator = new SubscriptionBusServiceBuilderConfiguratorImpl(stateMachineConfigurator); configurator.AddConfigurator(busServiceConfigurator); return(stateMachineConfigurator); }
public static ConsumerSubscriptionConfigurator Consumer( [NotNull] this SubscriptionBusServiceConfigurator 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 = (SubscriptionBuilderConfigurator) FastActivator.Create(typeof(UntypedConsumerSubscriptionConfigurator <>), new[] { consumerType }, new object[] { consumerFactory }); var busServiceConfigurator = new SubscriptionBusServiceBuilderConfiguratorImpl(consumerConfigurator); configurator.AddConfigurator(busServiceConfigurator); return(consumerConfigurator as ConsumerSubscriptionConfigurator); }