private async Task Subscribe(CancellationToken cancellationToken)
 {
     try
     {
         await _messageBus.SubscribeAsync <BusinessMessage>(Consumer, null, cancellationToken);
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, "");
     }
 }
Exemple #2
0
        private async Task Subscribe(CancellationToken cancellationToken)
        {
            try
            {
                await _messageBus.SubscribeAsync <BusinessMessage>(async (message) =>
                {
                    var current = Interlocked.Increment(ref Count);
                    //await Task.Delay(1000);
                    _logger.LogInformation($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff")}消费--1--数据:MessageId={message.MessageId},Content={message.Content},count={current}");

                    throw new Exception("333");
                    await Task.CompletedTask;
                }, null, cancellationToken);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "");
            }
        }