public DeferredMessagesManager(
            [NotNull] IDeferredMessagesRepository repository,
            TimeSpan delayPrecision,
            [NotNull] ILogFactory logFactory) :

            base(delayPrecision, logFactory)
        {
            _repository = repository ?? throw new ArgumentNullException(nameof(repository));
        }
 public DeferredMessagesManager(
     IDeferredMessagesRepository repository,
     TimeSpan delayPrecision,
     ILogger <DeferredMessagesManager> logger)
 {
     _repository = repository ?? throw new ArgumentNullException(nameof(repository));
     _period     = delayPrecision;
     _timer      = new Timer(Execute, null, TimeSpan.FromMilliseconds(-1), delayPrecision);
     _logger     = logger ?? throw new ArgumentNullException(nameof(logger));
 }
Esempio n. 3
0
        /// <summary>
        /// Enables deferred messages publishing using <see cref="ProduceAsync(TMessageModel,System.TimeSpan, string)"/>
        /// or <see cref="ProduceAsync(TMessageModel,System.DateTime, string)"/> methods
        /// </summary>
        /// <param name="repository">Deferred message repository instance</param>
        /// <param name="deliveryPrecision">
        /// The desired delivery time precision.
        /// Actually it determines the delay between deferred messages storage monitoring cycles.
        /// Default value is 1 second
        /// </param>
        /// <returns></returns>
        public RabbitMqPublisher <TMessageModel> EnableDeferredMessages(IDeferredMessagesRepository repository, TimeSpan?deliveryPrecision = null)
        {
            ThrowIfStarted();

            if (_log == null)
            {
                throw new InvalidOperationException($"Log should be set before {nameof(EnableDeferredMessages)} call");
            }

            _deferredMessagesManager?.Dispose();

            _deferredMessagesManager = _logFactory == null
                ? new DeferredMessagesManager(repository, deliveryPrecision ?? TimeSpan.FromSeconds(1), _log)
                : new DeferredMessagesManager(repository, deliveryPrecision ?? TimeSpan.FromSeconds(1), _logFactory);

            return(this);
        }
 public DeferredMessagesManager(IDeferredMessagesRepository repository, TimeSpan delayPrecision, ILog log) :
     base(nameof(DeferredMessagesManager), (int)delayPrecision.TotalMilliseconds, log)
 {
     _repository = repository;
 }