예제 #1
0
 private void Sending()
 {
     try
     {
         while (!_publishedMessageQueue.IsCompleted)
         {
             if (_publishedMessageQueue.TryTake(out var message, 3000, _cts.Token))
             {
                 Task.Run(async() =>
                 {
                     try
                     {
                         await _sender.SendAsync(message);
                     }
                     catch (Exception ex)
                     {
                         _logger.LogError(ex, $"An exception occurred when sending a message to the MQ. Topic:{message.Name}, Id:{message.Id}");
                     }
                 });
             }
         }
     }
     catch (OperationCanceledException)
     {
         // expected
     }
 }
예제 #2
0
        private async Task ProcessPublishedAsync(IStorageConnection connection, ProcessingContext context)
        {
            var messages = await GetSafelyAsync(connection.GetPublishedMessagesOfNeedRetry);

            foreach (var message in messages)
            {
                await _publishMessageSender.SendAsync(message);

                await context.WaitAsync(_delay);
            }
        }
예제 #3
0
 private void Sending()
 {
     try
     {
         while (!_publishedMessageQueue.IsCompleted)
         {
             if (_publishedMessageQueue.TryTake(out var message, 100, _cts.Token))
             {
                 try
                 {
                     _sender.SendAsync(message);
                 }
                 catch (Exception ex)
                 {
                     _logger.ExceptionOccuredWhileExecuting(message.Name, ex);
                 }
             }
         }
     }
     catch (OperationCanceledException)
     {
         // expected
     }
 }