public async Task StartAsync(CancellationToken cancellationToken)
 {
     await foreach (var id in _listener.GetMessagesAsync(cancellationToken))
     {
         await _eventProcessor.ProcessAsync(id);
     }
 }
Example #2
0
        public async Task ProcessAsync()
        {
            _logger.LogTrace("Starting fallback EventProcessor");

            var messages = (await _eventStore.GetUnpublishedAsync(TimeSpan.FromDays(FallbackDays))).ToArray();

            if (messages.Length == 0)
            {
                return;
            }

            _logger.LogInformation("Processing {EventCount} events in fallback EventProcessor", messages.Length);

            try
            {
                foreach (var message in messages)
                {
                    await _eventProcessor.ProcessAsync(message.Id);
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Error processing events in fallback EventProcessor");
            }
        }