示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandProcessor"/> class.
 /// Use this constructor when no task queue support is required and only async handlers are used
 /// </summary>
 /// <param name="subscriberRegistry">The subscriber registry.</param>
 /// <param name="asyncHandlerFactory">The async handler factory.</param>
 /// <param name="requestContextFactory">The request context factory.</param>
 /// <param name="policyRegistry">The policy registry.</param>
 /// <param name="logger">The logger.</param>
 public CommandProcessor(
     IAmASubscriberRegistry subscriberRegistry,
     IAmAHandlerFactoryAsync asyncHandlerFactory,
     IAmARequestContextFactory requestContextFactory,
     IAmAPolicyRegistry policyRegistry,
     ILog logger)
 {
     _subscriberRegistry    = subscriberRegistry;
     _asyncHandlerFactory   = asyncHandlerFactory;
     _requestContextFactory = requestContextFactory;
     _policyRegistry        = policyRegistry;
     _logger = logger;
 }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandProcessor"/> class.
 /// Use this constructor when only task queue support is required
 /// </summary>
 /// <param name="requestContextFactory">The request context factory.</param>
 /// <param name="policyRegistry">The policy registry.</param>
 /// <param name="mapperRegistry">The mapper registry.</param>
 /// <param name="asyncMessageStore">The message store supporting async/await.</param>
 /// <param name="asyncMessageProducer">The messaging gateway supporting async/await.</param>
 /// <param name="messageStoreTimeout">How long should we wait to write to the message store</param>
 public CommandProcessor(
     IAmARequestContextFactory requestContextFactory,
     IAmAPolicyRegistry policyRegistry,
     IAmAMessageMapperRegistry mapperRegistry,
     IAmAMessageStoreAsync <Message> asyncMessageStore,
     IAmAMessageProducerAsync asyncMessageProducer,
     int messageStoreTimeout = 300
     )
     : this(
         requestContextFactory, policyRegistry, mapperRegistry, asyncMessageStore, asyncMessageProducer,
         LogProvider.GetCurrentClassLogger(), messageStoreTimeout)
 {
 }
示例#3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandProcessor"/> class.
 /// Use this constructor when no task queue support is required and only async handlers are used
 /// </summary>
 /// <param name="subscriberRegistry">The subscriber registry.</param>
 /// <param name="asyncHandlerFactory">The async handler factory.</param>
 /// <param name="requestContextFactory">The request context factory.</param>
 /// <param name="policyRegistry">The policy registry.</param>
 /// <param name="featureSwitchRegistry">The feature switch config provider.</param>
 public CommandProcessor(
     IAmASubscriberRegistry subscriberRegistry,
     IAmAHandlerFactoryAsync asyncHandlerFactory,
     IAmARequestContextFactory requestContextFactory,
     IAmAPolicyRegistry policyRegistry,
     IAmAFeatureSwitchRegistry featureSwitchRegistry = null)
 {
     _subscriberRegistry    = subscriberRegistry;
     _asyncHandlerFactory   = asyncHandlerFactory;
     _requestContextFactory = requestContextFactory;
     _policyRegistry        = policyRegistry;
     _featureSwitchRegistry = featureSwitchRegistry;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandProcessor"/> class.
 /// Use this constructor when no task queue support is required
 /// </summary>
 /// <param name="subscriberRegistry">The subscriber registry.</param>
 /// <param name="handlerFactory">The handler factory.</param>
 /// <param name="requestContextFactory">The request context factory.</param>
 /// <param name="policyRegistry">The policy registry.</param>
 /// <param name="logger">The logger.</param>
 public CommandProcessor(
     IAmASubscriberRegistry subscriberRegistry,
     IAmAHandlerFactory handlerFactory,
     IAmARequestContextFactory requestContextFactory,
     IAmAPolicyRegistry policyRegistry,
     ILog logger)
 {
     this.subscriberRegistry    = subscriberRegistry;
     this.handlerFactory        = handlerFactory;
     this.requestContextFactory = requestContextFactory;
     this.policyRegistry        = policyRegistry;
     this.logger = logger;
 }
示例#5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandProcessor"/> class.
 /// Use this constructor when both task queue and command processor support is required
 /// </summary>
 /// <param name="subscriberRegistry">The subscriber registry.</param>
 /// <param name="handlerFactory">The handler factory.</param>
 /// <param name="requestContextFactory">The request context factory.</param>
 /// <param name="policyRegistry">The policy registry.</param>
 /// <param name="mapperRegistry">The mapper registry.</param>
 /// <param name="messageStore">The message store.</param>
 /// <param name="messageProducer">The messaging gateway.</param>
 /// <param name="messageStoreTimeout">How long should we wait to write to the message store</param>
 /// <param name="messageGatewaySendTimeout">How long should we wait to post to the message store</param>
 public CommandProcessor(
     IAmASubscriberRegistry subscriberRegistry,
     IAmAHandlerFactory handlerFactory,
     IAmARequestContextFactory requestContextFactory,
     IAmAPolicyRegistry policyRegistry,
     IAmAMessageMapperRegistry mapperRegistry,
     IAmAMessageStore <Message> messageStore,
     IAmAMessageProducer messageProducer,
     int messageStoreTimeout = 300
     )
     : this(subscriberRegistry, handlerFactory, requestContextFactory, policyRegistry, mapperRegistry, messageStore, messageProducer, LogProvider.For <CommandProcessor>(), messageStoreTimeout)
 {
 }
示例#6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandProcessor"/> class.
 /// Use this constructor when both task queue and command processor support is required
 /// </summary>
 /// <param name="subscriberRegistry">The subscriber registry.</param>
 /// <param name="handlerFactory">The handler factory.</param>
 /// <param name="requestContextFactory">The request context factory.</param>
 /// <param name="policyRegistry">The policy registry.</param>
 /// <param name="mapperRegistry">The mapper registry.</param>
 /// <param name="messageStore">The message store.</param>
 /// <param name="messageProducer">The messaging gateway.</param>
 /// <param name="messageStoreTimeout">How long should we wait to write to the message store</param>
 /// <param name="messageGatewaySendTimeout">How long should we wait to post to the message store</param>
 public CommandProcessor(
     IAmASubscriberRegistry subscriberRegistry,
     IAmAHandlerFactory handlerFactory,
     IAmARequestContextFactory requestContextFactory,
     IAmAPolicyRegistry policyRegistry,
     IAmAMessageMapperRegistry mapperRegistry,
     IAmAMessageStore <Message> messageStore,
     IAmAMessageProducer messageProducer,
     int messageStoreTimeout       = 300,
     int messageGatewaySendTimeout = 300
     )
     : this(subscriberRegistry, handlerFactory, requestContextFactory, policyRegistry, mapperRegistry, messageStore, messageProducer, LogProvider.GetCurrentClassLogger())
 {
 }
示例#7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandProcessor"/> class.
 /// Use this constructor when both task queue and command processor support is required
 /// </summary>
 /// <param name="subscriberRegistry">The subscriber registry.</param>
 /// <param name="handlerFactory">The handler factory.</param>
 /// <param name="requestContextFactory">The request context factory.</param>
 /// <param name="policyRegistry">The policy registry.</param>
 /// <param name="mapperRegistry">The mapper registry.</param>
 /// <param name="messageStore">The message store.</param>
 /// <param name="messagingGateway">The messaging gateway.</param>
 /// <param name="logger">The logger.</param>
 public CommandProcessor(
     IAmASubscriberRegistry subscriberRegistry,
     IAmAHandlerFactory handlerFactory,
     IAmARequestContextFactory requestContextFactory,
     IAmAPolicyRegistry policyRegistry,
     IAmAMessageMapperRegistry mapperRegistry,
     IAmAMessageStore <Message> messageStore,
     IAmAMessageProducer messagingGateway,
     ILog logger)
     : this(subscriberRegistry, handlerFactory, requestContextFactory, policyRegistry, logger)
 {
     this.mapperRegistry   = mapperRegistry;
     this.messageStore     = messageStore;
     this.messagingGateway = messagingGateway;
 }
        /// <summary>
        /// Supplies the specified the policy registry, so we can use policies for Task Queues or in user-defined request handlers such as ExceptionHandler
        /// that provide quality of service concerns
        /// </summary>
        /// <param name="thePolicyRegistry">The policy registry.</param>
        /// <returns>INeedLogging.</returns>
        /// <exception cref="ConfigurationException">The policy registry is missing the CommandProcessor.RETRYPOLICY policy which is required</exception>
        /// <exception cref="ConfigurationException">The policy registry is missing the CommandProcessor.CIRCUITBREAKER policy which is required</exception>
        public INeedMessaging Policies(IAmAPolicyRegistry thePolicyRegistry)
        {
            if (!thePolicyRegistry.Has(CommandProcessor.RETRYPOLICY))
            {
                throw new ConfigurationException("The policy registry is missing the CommandProcessor.RETRYPOLICY policy which is required");
            }

            if (!thePolicyRegistry.Has(CommandProcessor.CIRCUITBREAKER))
            {
                throw new ConfigurationException("The policy registry is missing the CommandProcessor.CIRCUITBREAKER policy which is required");
            }

            _policyRegistry = thePolicyRegistry;
            return(this);
        }
示例#9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandProcessor"/> class.
 /// Use this constructor when only task queue support is required
 /// </summary>
 /// <param name="requestContextFactory">The request context factory.</param>
 /// <param name="policyRegistry">The policy registry.</param>
 /// <param name="mapperRegistry">The mapper registry.</param>
 /// <param name="asyncMessageStore">The message store supporting async/await.</param>
 /// <param name="asyncMessageProducer">The messaging gateway supporting async/await.</param>
 /// <param name="messageStoreTimeout">How long should we wait to write to the message store</param>
 public CommandProcessor(
     IAmARequestContextFactory requestContextFactory,
     IAmAPolicyRegistry policyRegistry,
     IAmAMessageMapperRegistry mapperRegistry,
     IAmAMessageStoreAsync <Message> asyncMessageStore,
     IAmAMessageProducerAsync asyncMessageProducer,
     int messageStoreTimeout = 300)
 {
     _requestContextFactory = requestContextFactory;
     _policyRegistry        = policyRegistry;
     _messageStoreTimeout   = messageStoreTimeout;
     _mapperRegistry        = mapperRegistry;
     _asyncMessageStore     = asyncMessageStore;
     _asyncMessageProducer  = asyncMessageProducer;
 }
示例#10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandProcessor"/> class.
 /// Use this constructor when only task queue support is required
 /// </summary>
 /// <param name="requestContextFactory">The request context factory.</param>
 /// <param name="policyRegistry">The policy registry.</param>
 /// <param name="mapperRegistry">The mapper registry.</param>
 /// <param name="messageStore">The message store.</param>
 /// <param name="messagingGateway">The messaging gateway.</param>
 /// <param name="logger">The logger.</param>
 public CommandProcessor(
     IAmARequestContextFactory requestContextFactory,
     IAmAPolicyRegistry policyRegistry,
     IAmAMessageMapperRegistry mapperRegistry,
     IAmAMessageStore <Message> messageStore,
     IAmAMessageProducer messagingGateway,
     ILog logger)
 {
     this.requestContextFactory = requestContextFactory;
     this.policyRegistry        = policyRegistry;
     this.logger           = logger;
     this.mapperRegistry   = mapperRegistry;
     this.messageStore     = messageStore;
     this.messagingGateway = messagingGateway;
 }
示例#11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandProcessor"/> class.
 /// Use this constructor when both task queue and command processor support is required
 /// </summary>
 /// <param name="subscriberRegistry">The subscriber registry.</param>
 /// <param name="asyncHandlerFactory">The async handler factory.</param>
 /// <param name="requestContextFactory">The request context factory.</param>
 /// <param name="policyRegistry">The policy registry.</param>
 /// <param name="mapperRegistry">The mapper registry.</param>
 /// <param name="asyncMessageStore">The message store supporting async/await.</param>
 /// <param name="asyncMessageProducer">The messaging gateway supporting async/await.</param>
 /// <param name="messageStoreTimeout">How long should we wait to write to the message store</param>
 public CommandProcessor(
     IAmASubscriberRegistry subscriberRegistry,
     IAmAHandlerFactoryAsync asyncHandlerFactory,
     IAmARequestContextFactory requestContextFactory,
     IAmAPolicyRegistry policyRegistry,
     IAmAMessageMapperRegistry mapperRegistry,
     IAmAMessageStoreAsync <Message> asyncMessageStore,
     IAmAMessageProducerAsync asyncMessageProducer,
     int messageStoreTimeout = 300)
     : this(subscriberRegistry, asyncHandlerFactory, requestContextFactory, policyRegistry)
 {
     _mapperRegistry       = mapperRegistry;
     _asyncMessageStore    = asyncMessageStore;
     _asyncMessageProducer = asyncMessageProducer;
     _messageStoreTimeout  = messageStoreTimeout;
 }
示例#12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandProcessor"/> class.
 /// Use this constructor when only task queue support is required
 /// </summary>
 /// <param name="requestContextFactory">The request context factory.</param>
 /// <param name="policyRegistry">The policy registry.</param>
 /// <param name="mapperRegistry">The mapper registry.</param>
 /// <param name="messageStore">The message store.</param>
 /// <param name="messageProducer">The messaging gateway.</param>
 /// <param name="messageStoreTimeout">How long should we wait to write to the message store</param>
 /// <param name="featureSwitchRegistry">The feature switch config provider.</param>
 public CommandProcessor(
     IAmARequestContextFactory requestContextFactory,
     IAmAPolicyRegistry policyRegistry,
     IAmAMessageMapperRegistry mapperRegistry,
     IAmAMessageStore <Message> messageStore,
     IAmAMessageProducer messageProducer,
     int messageStoreTimeout = 300,
     IAmAFeatureSwitchRegistry featureSwitchRegistry = null)
 {
     _requestContextFactory = requestContextFactory;
     _policyRegistry        = policyRegistry;
     _messageStoreTimeout   = messageStoreTimeout;
     _mapperRegistry        = mapperRegistry;
     _messageStore          = messageStore;
     _messageProducer       = messageProducer;
     _featureSwitchRegistry = featureSwitchRegistry;
 }
示例#13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandProcessor"/> class.
 /// Use this constructor when both rpc and command processor support is required
 /// </summary>
 /// <param name="subscriberRegistry">The subscriber registry.</param>
 /// <param name="handlerFactory">The handler factory.</param>
 /// <param name="requestContextFactory">The request context factory.</param>
 /// <param name="policyRegistry">The policy registry.</param>
 /// <param name="mapperRegistry">The mapper registry.</param>
 /// <param name="messageStore">The message store.</param>
 /// <param name="messageProducer">The messaging gateway.</param>
 /// <param name="responseChannelFactory">If we are expecting a response, then we need a channel to listen on</param>
 /// <param name="messageStoreTimeout">How long should we wait to write to the message store</param>
 /// <param name="featureSwitchRegistry">The feature switch config provider.</param>
 public CommandProcessor(
     IAmASubscriberRegistry subscriberRegistry,
     IAmAHandlerFactory handlerFactory,
     IAmARequestContextFactory requestContextFactory,
     IAmAPolicyRegistry policyRegistry,
     IAmAMessageMapperRegistry mapperRegistry,
     IAmAMessageProducer messageProducer,
     int messageStoreTimeout = 300,
     IAmAFeatureSwitchRegistry featureSwitchRegistry = null,
     IAmAChannelFactory responseChannelFactory       = null)
     : this(subscriberRegistry, handlerFactory, requestContextFactory, policyRegistry)
 {
     _mapperRegistry         = mapperRegistry;
     _messageProducer        = messageProducer;
     _messageStoreTimeout    = messageStoreTimeout;
     _featureSwitchRegistry  = featureSwitchRegistry;
     _responseChannelFactory = responseChannelFactory;
 }
示例#14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandProcessor"/> class.
 /// Use this constructor when only task queue support is required, and you wish to inject a test logger
 /// </summary>
 /// <param name="requestContextFactory">The request context factory.</param>
 /// <param name="policyRegistry">The policy registry.</param>
 /// <param name="mapperRegistry">The mapper registry.</param>
 /// <param name="messageStore">The message store.</param>
 /// <param name="messageProducer">The messaging gateway.</param>
 /// <param name="logger">The logger.</param>
 /// <param name="messageStoreTimeout">How long should we wait to write to the message store</param>
 public CommandProcessor(
     IAmARequestContextFactory requestContextFactory,
     IAmAPolicyRegistry policyRegistry,
     IAmAMessageMapperRegistry mapperRegistry,
     IAmAMessageStore <Message> messageStore,
     IAmAMessageProducer messageProducer,
     ILog logger,
     int messageStoreTimeout = 300
     )
 {
     _requestContextFactory = requestContextFactory;
     _policyRegistry        = policyRegistry;
     _logger = logger;
     _messageStoreTimeout = messageStoreTimeout;
     _mapperRegistry      = mapperRegistry;
     _messageStore        = messageStore;
     _messageProducer     = messageProducer;
 }
示例#15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandProcessor"/> class.
 /// Use this constructor when both task queue and command processor support is required, and you want to inject a test logger
 /// </summary>
 /// <param name="subscriberRegistry">The subscriber registry.</param>
 /// <param name="handlerFactory">The handler factory.</param>
 /// <param name="requestContextFactory">The request context factory.</param>
 /// <param name="policyRegistry">The policy registry.</param>
 /// <param name="mapperRegistry">The mapper registry.</param>
 /// <param name="messageStore">The message store.</param>
 /// <param name="messageProducer">The messaging gateway.</param>
 /// <param name="logger">The logger.</param>
 /// <param name="messageStoreTimeout">How long should we wait to write to the message store</param>
 public CommandProcessor(
     IAmASubscriberRegistry subscriberRegistry,
     IAmAHandlerFactory handlerFactory,
     IAmARequestContextFactory requestContextFactory,
     IAmAPolicyRegistry policyRegistry,
     IAmAMessageMapperRegistry mapperRegistry,
     IAmAMessageStore <Message> messageStore,
     IAmAMessageProducer messageProducer,
     ILog logger,
     int messageStoreTimeout = 300
     )
     : this(subscriberRegistry, handlerFactory, requestContextFactory, policyRegistry, logger)
 {
     _mapperRegistry      = mapperRegistry;
     _messageStore        = messageStore;
     _messageProducer     = messageProducer;
     _messageStoreTimeout = messageStoreTimeout;
 }
示例#16
0
 /// <summary>
 /// Supplies the specified the policy registry, so we can use policies for Task Queues or in user-defined request handlers such as ExceptionHandler
 /// that provide quality of service concerns
 /// </summary>
 /// <param name="thePolicyRegistry">The policy registry.</param>
 /// <returns>INeedLogging.</returns>
 public INeedLogging Policies(IAmAPolicyRegistry thePolicyRegistry)
 {
     _policyRegistry = thePolicyRegistry;
     return this;
 }
 /// <summary>
 /// Use this if you do not require a policy and only want to retry once(i.e. No Tasks Queues or QoS needs).
 /// </summary>
 /// <returns>INeedLogging.</returns>
 public INeedMessaging DefaultPolicy()
 {
     _policyRegistry = new DefaultPolicy();
     return(this);
 }
 /// <summary>
 /// Supplies the specified the policy registry, so we can use policies for Task Queues or in user-defined request handlers such as ExceptionHandler
 /// that provide quality of service concerns
 /// </summary>
 /// <param name="thePolicyRegistry">The policy registry.</param>
 /// <returns>INeedLogging.</returns>
 public INeedLogging Policies(IAmAPolicyRegistry thePolicyRegistry)
 {
     policyRegistry = thePolicyRegistry;
     return(this);
 }
示例#19
0
 /// <summary>
 /// Use this if you do not require a policy and only want to retry once(i.e. No Tasks Queues or QoS needs).
 /// </summary>
 /// <returns>INeedLogging.</returns>
 public INeedLogging DefaultPolicy()
 {
     _policyRegistry = new DefaultPolicy();
     return this;
 }
示例#20
0
 /// <summary>
 /// Supplies the specified the policy registry, so we can use policies for Task Queues or in user-defined request handlers such as ExceptionHandler
 /// that provide quality of service concerns
 /// </summary>
 /// <param name="thePolicyRegistry">The policy registry.</param>
 /// <returns>INeedLogging.</returns>
 /// <exception cref="ConfigurationException">The policy registry is missing the CommandProcessor.RETRYPOLICY policy which is required</exception>
 /// <exception cref="ConfigurationException">The policy registry is missing the CommandProcessor.CIRCUITBREAKER policy which is required</exception>
 public INeedLogging Policies(IAmAPolicyRegistry thePolicyRegistry)
 {
     if (!thePolicyRegistry.Has(CommandProcessor.RETRYPOLICY))
         throw new ConfigurationException("The policy registry is missing the CommandProcessor.RETRYPOLICY policy which is required");
         
     if (!thePolicyRegistry.Has(CommandProcessor.CIRCUITBREAKER))
         throw new ConfigurationException("The policy registry is missing the CommandProcessor.CIRCUITBREAKER policy which is required");
     
     _policyRegistry = thePolicyRegistry;
     return this;
 }