示例#1
0
        public static void UseRetry(this IBusFactoryConfigurator configurator, Action <IRetryConfigurator> configure)
        {
            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }

            var observer = new RetryBusObserver();

            configurator.ConnectBusObserver(observer);

            var specification = new ConsumeContextRetryPipeSpecification(observer.Stopping);

            configure?.Invoke(specification);

            configurator.AddPipeSpecification(specification);
        }
        /// <summary>
        /// Configures the message retry for the consumer consumer, regardless of message type.
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="busFactoryConfigurator">
        /// The bus factory configurator, to connect the observer, to cancel retries if the bus is stopped
        /// </param>
        /// <param name="configure"></param>
        public static void UseMessageRetry <TConsumer>(this IConsumerConfigurator <TConsumer> configurator, IBusFactoryConfigurator busFactoryConfigurator,
                                                       Action <IRetryConfigurator> configure)
            where TConsumer : class
        {
            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }

            var retryObserver = new RetryBusObserver();

            busFactoryConfigurator.ConnectBusObserver(retryObserver);

            var observer = new MessageRetryConsumerConfigurationObserver <TConsumer>(configurator, retryObserver.Stopping, configure);

            configurator.ConnectConsumerConfigurationObserver(observer);
        }
示例#3
0
        /// <summary>
        /// For all configured messages type (handlers, consumers, and sagas), configures message retry using the retry configuration specified.
        /// Retry is configured once for each message type, and is added prior to the consumer factory or saga repository in the pipeline.
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="connector">The bus factory configurator, to connect the observer, to cancel retries if the bus is stopped</param>
        /// <param name="configureRetry"></param>
        public static void UseMessageRetry(this IConsumePipeConfigurator configurator, IBusFactoryConfigurator connector, Action <IRetryConfigurator> configureRetry)
        {
            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }

            if (configureRetry == null)
            {
                throw new ArgumentNullException(nameof(configureRetry));
            }

            var retryObserver = new RetryBusObserver();

            connector.ConnectBusObserver(retryObserver);

            var observer = new RetryConfigurationObserver(configurator, retryObserver.Stopping, configureRetry);
        }
示例#4
0
        public static void UseRetry <TSaga>(this IPipeConfigurator <SagaConsumeContext <TSaga> > configurator, IBusFactoryConfigurator connector, Action <IRetryConfigurator> configure)
            where TSaga : class, ISaga
        {
            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }

            var observer = new RetryBusObserver();

            connector.ConnectBusObserver(observer);

            var specification = new ConsumeContextRetryPipeSpecification <SagaConsumeContext <TSaga>, RetrySagaConsumeContext <TSaga> >(Factory, observer.Stopping);

            configure?.Invoke(specification);

            configurator.AddPipeSpecification(specification);
        }