Exemplo n.º 1
0
    protected virtual async Task Timer_Elapsed(AbpAsyncTimer timer)
    {
        await CreateTopicAsync();

        Consume();
        Timer.Stop();
    }
 protected AsyncPeriodicBackgroundWorkerBase(
     AbpAsyncTimer timer,
     IServiceScopeFactory serviceScopeFactory)
 {
     ServiceScopeFactory = serviceScopeFactory;
     Timer         = timer;
     Timer.Elapsed = Timer_Elapsed;
 }
Exemplo n.º 3
0
 protected virtual async Task Timer_Elapsed(AbpAsyncTimer timer)
 {
     if (Channel == null || Channel.IsOpen == false)
     {
         await TryCreateChannelAsync();
         await TrySendQueueBindCommandsAsync();
     }
 }
Exemplo n.º 4
0
 public MonitorWorker(
     AbpAsyncTimer timer,
     IServiceScopeFactory serviceScopeFactory,
     IDistributedEventBus distributedEventBus)
     : base(timer, serviceScopeFactory)
 {
     _distributedEventBus = distributedEventBus;
     Timer.Period         = (int)KetumConsts.MonitorWorkerPeriod.TotalMilliseconds;
 }
Exemplo n.º 5
0
 public FileCheckerWorker(
     AbpAsyncTimer timer,
     IServiceScopeFactory serviceScopeFactory
     ) : base(
         timer,
         serviceScopeFactory)
 {
     Timer.Period = 600000; //10 minutes
 }
Exemplo n.º 6
0
    protected virtual async Task Timer_Elapsed(AbpAsyncTimer timer)
    {
        if (Consumer == null)
        {
            await CreateTopicAsync();

            Consume();
        }
    }
 public NotificationCleanupBackgroundWorker(
     AbpAsyncTimer timer,
     IServiceScopeFactory serviceScopeFactory,
     IOptions <AbpNotificationCleanupOptions> options)
     : base(timer, serviceScopeFactory)
 {
     Options      = options.Value;
     timer.Period = Options.CleanupPeriod;
 }
Exemplo n.º 8
0
 public TokenCleanupBackgroundWorker(
     AbpAsyncTimer timer,
     IServiceScopeFactory serviceScopeFactory,
     IOptionsMonitor <TokenCleanupOptions> cleanupOptions,
     IAbpDistributedLock distributedLock)
     : base(timer, serviceScopeFactory)
 {
     DistributedLock = distributedLock;
     timer.Period    = cleanupOptions.CurrentValue.CleanupPeriod;
 }
 /// <summary>
 /// Handles the Elapsed event of the Timer.
 /// </summary>
 private async Task Timer_Elapsed(AbpAsyncTimer timer)
 {
     try
     {
         await DoWorkAsync();
     }
     catch (Exception ex)
     {
         Logger.Warn(ex.ToString(), ex);
     }
 }
        public ExchangeRateUpdateBackgroundWorker(AbpAsyncTimer timer,
                                                  IServiceScopeFactory serviceScopeFactory,
                                                  ICurrencyRepository reository,
                                                  IExchangeRateApiService exchangeRateApiService
                                                  ) : base(timer, serviceScopeFactory)
        {
            _reository = reository;
            _exchangeRateApiService = exchangeRateApiService;

            // 每x小时更新一次汇率
            Timer.Period = 12 * 3600;
        }
Exemplo n.º 11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BackgroundJobManager"/> class.
        /// </summary>
        public BackgroundJobManager(
            IIocResolver iocResolver,
            IBackgroundJobStore store,
            AbpAsyncTimer timer)
            : base(timer)
        {
            _store       = store;
            _iocResolver = iocResolver;

            EventBus = NullEventBus.Instance;

            Timer.Period = JobPollPeriod;
        }
Exemplo n.º 12
0
 public BackgroundJobWorker(
     AbpAsyncTimer timer,
     IOptions <AbpBackgroundJobOptions> jobOptions,
     IOptions <AbpBackgroundJobWorkerOptions> workerOptions,
     IServiceScopeFactory serviceScopeFactory)
     : base(
         timer,
         serviceScopeFactory)
 {
     WorkerOptions = workerOptions.Value;
     JobOptions    = jobOptions.Value;
     Timer.Period  = WorkerOptions.JobPollPeriod;
 }
        /// <summary>
        /// 创建过期消息清理任务
        /// </summary>
        /// <param name="timer"></param>
        /// <param name="storage"></param>
        /// <param name="initializer"></param>
        /// <param name="options"></param>
        /// <param name="serviceScopeFactory"></param>
        public AbpCapExpiresMessageCleanupBackgroundWorker(
            AbpAsyncTimer timer,
            IDataStorage storage,
            IStorageInitializer initializer,
            IOptions <AbpCAPEventBusOptions> options,
            IServiceScopeFactory serviceScopeFactory)
            : base(timer, serviceScopeFactory)
        {
            Storage     = storage;
            Options     = options.Value;
            Initializer = initializer;

            timer.Period = Options.CleanUpExpiresMessageInterval;
        }
Exemplo n.º 14
0
 public BackgroundJobWorker(
     AbpAsyncTimer timer,
     IOptions <AbpBackgroundJobOptions> jobOptions,
     IOptions <AbpBackgroundJobWorkerOptions> workerOptions,
     IServiceScopeFactory serviceScopeFactory,
     IAbpDistributedLock distributedLock)
     : base(
         timer,
         serviceScopeFactory)
 {
     DistributedLock = distributedLock;
     WorkerOptions   = workerOptions.Value;
     JobOptions      = jobOptions.Value;
     Timer.Period    = WorkerOptions.JobPollPeriod;
 }
Exemplo n.º 15
0
        public RabbitMqMessageConsumer(
            IConnectionPool connectionPool,
            AbpAsyncTimer timer,
            IExceptionNotifier exceptionNotifier)
        {
            ConnectionPool    = connectionPool;
            Timer             = timer;
            ExceptionNotifier = exceptionNotifier;
            Logger            = NullLogger <RabbitMqMessageConsumer> .Instance;

            QueueBindCommands = new ConcurrentQueue <QueueBindCommand>();
            Callbacks         = new ConcurrentBag <Func <IModel, BasicDeliverEventArgs, Task> >();

            Timer.Period     = 5000; //5 sec.
            Timer.Elapsed    = Timer_Elapsed;
            Timer.RunOnStart = true;
        }
Exemplo n.º 16
0
 public OutboxSender(
     IServiceProvider serviceProvider,
     AbpAsyncTimer timer,
     IDistributedEventBus distributedEventBus,
     IAbpDistributedLock distributedLock,
     IOptions <AbpEventBusBoxesOptions> eventBusBoxesOptions)
 {
     ServiceProvider      = serviceProvider;
     DistributedEventBus  = distributedEventBus;
     DistributedLock      = distributedLock;
     EventBusBoxesOptions = eventBusBoxesOptions.Value;
     Timer               = timer;
     Timer.Period        = Convert.ToInt32(EventBusBoxesOptions.PeriodTimeSpan.TotalMilliseconds);
     Timer.Elapsed      += TimerOnElapsed;
     Logger              = NullLogger <OutboxSender> .Instance;
     StoppingTokenSource = new CancellationTokenSource();
     StoppingToken       = StoppingTokenSource.Token;
 }
Exemplo n.º 17
0
    public KafkaMessageConsumer(
        IConsumerPool consumerPool,
        IExceptionNotifier exceptionNotifier,
        IOptions <AbpKafkaOptions> options,
        IProducerPool producerPool,
        AbpAsyncTimer timer)
    {
        ConsumerPool      = consumerPool;
        ExceptionNotifier = exceptionNotifier;
        ProducerPool      = producerPool;
        Timer             = timer;
        Options           = options.Value;
        Logger            = NullLogger <KafkaMessageConsumer> .Instance;

        Callbacks = new ConcurrentBag <Func <Message <string, byte[]>, Task> >();

        Timer.Period     = 5000; //5 sec.
        Timer.Elapsed    = Timer_Elapsed;
        Timer.RunOnStart = true;
    }
Exemplo n.º 18
0
 public FileCrawlerRecordDownloadingWorker(AbpAsyncTimer timer, IServiceScopeFactory serviceScopeFactory) : base(timer, serviceScopeFactory)
 {
     Timer.Period = 60000; //1 minute
 }
Exemplo n.º 19
0
 private async Task Timer_Elapsed(AbpAsyncTimer timer)
 {
     await DoWorkAsync(StartCancellationToken);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PeriodicBackgroundWorkerBase"/> class.
 /// </summary>
 /// <param name="timer">A timer.</param>
 protected AsyncPeriodicBackgroundWorkerBase(AbpAsyncTimer timer)
 {
     Timer          = timer;
     Timer.Elapsed += Timer_Elapsed;
 }
 private async Task Timer_Elapsed(AbpAsyncTimer timer)
 {
     await DoWorkAsync();
 }
Exemplo n.º 22
0
 public LogConfigCheckWorker(AbpAsyncTimer timer, IServiceScopeFactory serviceScopeFactory, INLogConfigLoader configLoader) : base(timer, serviceScopeFactory)
 {
     _configLoader = configLoader;
     Timer.Period  = 5000; //5 sec
 }
Exemplo n.º 23
0
 private async Task TimerOnElapsed(AbpAsyncTimer arg)
 {
     await RunAsync();
 }
Exemplo n.º 24
0
 public MonedaUpdateWorker(AbpAsyncTimer timer, IServiceScopeFactory serviceScopeFactory) : base(timer, serviceScopeFactory)
 {
     Timer.Period = 3600000; //1 hora
 }