コード例 #1
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            var queue = await _sub.SubscribeAsync("orders");

            while (!stoppingToken.IsCancellationRequested)
            {
                try
                {
                    var queueMessage = await queue.ReadAsync(stoppingToken);

                    var orderMessage = OrderMessage.FromBytes(queueMessage.Message);
                    await _orderMessages.WriteAsync(orderMessage, stoppingToken);
                }
                catch (OperationCanceledException)
                {
                    _log.LogInformation("Service stopping.");
                    break;
                }
            }
        }
コード例 #2
0
 internal ValueTask WriteAsync(OrderMessage message, CancellationToken token) =>
 _channel.Writer.WriteAsync(message, token);