public static void ConsumerTask() { var minuteConsumer = new KafkaConsumer("hour-consumer", "localhost:9092"); minuteConsumer.ConstructConsumer("hour"); var cts = new CancellationTokenSource(); Console.CancelKeyPress += (_, e) => { e.Cancel = true; cts.Cancel(); }; try { while (true) { try { var minuteMessage = minuteConsumer.Consumer.Consume(cts.Token); Console.Clear(); Colorful.Console.WriteAscii(minuteMessage.Value, Color.Green); } catch (ConsumeException ex) { Console.WriteLine($"Error ocurrect: {ex.Error.Reason}"); } } } catch (OperationCanceledException) { minuteConsumer.Consumer.Close(); } }