public ResilientErrorHandlingStrategy(
            [NotNull] ILogFactory logFactory,
            [NotNull] RabbitMqSubscriptionSettings settings,
            TimeSpan retryTimeout,
            int retryNum = 5,
            IErrorHandlingStrategy next = null)
        {
            if (logFactory == null)
            {
                throw new ArgumentNullException(nameof(logFactory));
            }
            if (retryTimeout <= TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException(nameof(retryTimeout), retryTimeout, "Should be positive time span");
            }
            if (retryNum <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(retryNum), retryNum, "Should be positive number");
            }

            _log          = logFactory.CreateLog(this);
            _settings     = settings ?? throw new ArgumentNullException(nameof(settings));
            _retryTimeout = retryTimeout;
            _retryNum     = retryNum;
            _next         = next;
        }
 public EventingBasicConsumerFactory(IChannelFactory channelFactory, IErrorHandlingStrategy strategy)
 {
     _channelFactory = channelFactory;
     _strategy = strategy;
     _processedButNotAcked = new ConcurrentBag<string>();
     _consumers = new ConcurrentBag<IRawConsumer>();
 }
 public EthereumEventsErrorHandlingStrategy(
     [NotNull] IErrorHandlingStrategy defaultStrategy,
     [NotNull] IErrorHandlingStrategy badRequestStrategy)
 {
     _defaultStrategy    = defaultStrategy;
     _badRequestStrategy = badRequestStrategy;
 }
Exemple #4
0
 public RabbitMqSubscriber(
     RabbitMqSubscriptionSettings settings,
     IErrorHandlingStrategy errorHandlingStrategy,
     bool submitTelemetry = true)
 {
     _settings = settings;
     _errorHandlingStrategy = errorHandlingStrategy;
     _submitTelemetry       = submitTelemetry;
     _exchangeQueueName     = _settings.GetQueueOrExchangeName();
 }
Exemple #5
0
 public EasyNetQSubscriber(IErrorHandlingStrategy errorHandlingStrategy, IAdvancedBus bus, IQueue queue, ushort prefetchcount,
                           ISubscriptionSelector subscriptionSelector, ISuccessHandlingStrategy successHandlingStrategy, IDisposable nameHandle)
 {
     _errorHandlingStrategy   = errorHandlingStrategy;
     _successHandlingStrategy = successHandlingStrategy;
     _bus                  = bus;
     _queue                = queue;
     _prefetchcount        = prefetchcount;
     _subscriptionSelector = subscriptionSelector;
     _nameHandle           = nameHandle;
 }
Exemple #6
0
        /// <inheritdoc />
        public void RemoveStrategy(IErrorHandlingStrategy strategy)
        {
            if (strategy == null)
            {
                throw new ArgumentNullException(nameof(strategy));
            }
            else if (!strategies.Contains(strategy))
            {
                throw new ArgumentException("The strategy does not exist within the composite strategy.");
            }

            strategies.Remove(strategy);
        }
Exemple #7
0
        /// <inheritdoc />
        public void AddStrategy(IErrorHandlingStrategy strategy)
        {
            if (strategy == null)
            {
                throw new ArgumentNullException(nameof(strategy));
            }
            else if (strategies.Contains(strategy))
            {
                throw new ArgumentException("The strategy has already been added to the composite strategy.");
            }

            strategies.Add(strategy);
        }
        public DefaultErrorHandlingStrategy(
            [NotNull] ILogFactory logFactory,
            [NotNull] RabbitMqSubscriptionSettings settings,
            IErrorHandlingStrategy next = null)
        {
            if (logFactory == null)
            {
                throw new ArgumentNullException(nameof(logFactory));
            }

            _log      = logFactory.CreateLog(this);
            _settings = settings ?? throw new ArgumentNullException(nameof(settings));
            _next     = next;
        }
        public ResilientErrorHandlingStrategy(ILog log, RabbitMqSubscriptionSettings settings, TimeSpan retryTimeout, int retryNum = 5, IErrorHandlingStrategy next = null)
        {
            if (log == null)
            {
                throw new ArgumentNullException(nameof(log));
            }
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            _log          = log;
            _settings     = settings;
            _retryTimeout = retryTimeout;
            _retryNum     = retryNum;
            _next         = next;
        }
Exemple #10
0
        public RabbitMqSubscriber(
            [NotNull] ILogFactory logFactory,
            [NotNull] RabbitMqSubscriptionSettings settings,
            [NotNull] IErrorHandlingStrategy errorHandlingStrategy,
            bool submitTelemetry       = true,
            IDeduplicator deduplicator = null)
        {
            if (logFactory == null)
            {
                throw new ArgumentNullException(nameof(logFactory));
            }

            _log      = logFactory.CreateLog(this);
            _settings = settings ?? throw new ArgumentNullException(nameof(settings));
            _errorHandlingStrategy = errorHandlingStrategy ?? throw new ArgumentNullException(nameof(errorHandlingStrategy));
            _submitTelemetry       = submitTelemetry;
            _exchangeQueueName     = _settings.GetQueueOrExchangeName();
        }
Exemple #11
0
 public Subscriber(
     IChannelFactory channelFactory,
     IConsumerFactory consumerFactory,
     ITopologyProvider topologyProvider,
     IMessageSerializer serializer,
     IMessageContextProvider <TMessageContext> contextProvider,
     IContextEnhancer contextEnhancer,
     IErrorHandlingStrategy errorHandling,
     RawRabbitConfiguration config)
 {
     _channelFactory   = channelFactory;
     _consumerFactory  = consumerFactory;
     _topologyProvider = topologyProvider;
     _serializer       = serializer;
     _contextProvider  = contextProvider;
     _contextEnhancer  = contextEnhancer;
     _errorHandling    = errorHandling;
     _config           = config;
     _subscriptions    = new List <ISubscription>();
 }
Exemple #12
0
 public Requester(
     IChannelFactory channelFactory,
     IConsumerFactory consumerFactory,
     IMessageSerializer serializer,
     IMessageContextProvider <TMessageContext> contextProvider,
     IErrorHandlingStrategy errorStrategy,
     IBasicPropertiesProvider propertiesProvider,
     ITopologyProvider topologyProvider,
     RawRabbitConfiguration config)
 {
     _channelFactory            = channelFactory;
     _consumerFactory           = consumerFactory;
     _serializer                = serializer;
     _contextProvider           = contextProvider;
     _errorStrategy             = errorStrategy;
     _propertiesProvider        = propertiesProvider;
     _topologyProvider          = topologyProvider;
     _config                    = config;
     _responseDictionary        = new ConcurrentDictionary <string, ResponseCompletionSource>();
     _consumerCompletionSources = new ConcurrentDictionary <IModel, ConsumerCompletionSource>();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="StrategyErrorHandler"/> class.
 /// </summary>
 /// <param name="errorHandlingStrategy">The error handling strategy to handle the errors.</param>
 public StrategyErrorHandler(IErrorHandlingStrategy errorHandlingStrategy)
 {
     this.errorHandlingStrategy = errorHandlingStrategy ?? throw new ArgumentNullException(nameof(errorHandlingStrategy));
 }
 public DefaultErrorHandlingStrategy(ILog log, RabbitMqSubscriptionSettings settings, IErrorHandlingStrategy next = null)
 {
     _log      = log ?? throw new ArgumentNullException(nameof(log));
     _settings = settings ?? throw new ArgumentNullException(nameof(settings));
     _next     = next;
 }
 public RmqSubscriber(string connectionString, string queueName, IErrorHandlingStrategy errorHandlingStrategy = null)
     : base(connectionString)
 {
     this.queueName             = queueName;
     this.errorHandlingStrategy = errorHandlingStrategy ?? new ErrorHandlingStrategy();
 }