static void Main(string[] args) { if (!StartUpService()) { return; } using (var consumer = _pubSubProvider .GetConsumerProvider(_kafkaSettings.BrokerList, _kafkaSettings.OrderTopic, _kafkaSettings.ConsumerGroupId, _kafkaSettings.Partition)) { while (true) { var orderValue = new Common.DataModels.Order(); try { Message <Null, string> msg; if (consumer.Consume(out msg, TimeSpan.FromMilliseconds(100))) { orderValue = Serializer.Deserialize <Common.DataModels.Order>(msg.Value); var commit = Task.Run(() => _orderServiceManager.CommitOrder(orderValue)); commit.Wait(); if (commit.Result) { if (!string.IsNullOrEmpty(orderValue.OrderId)) { Task.Run(() => _logProvider.PublishInfo(orderValue.EventID, "Order Success -" + JsonConvert.SerializeObject(orderValue))); _metricsProvider.RestCounterIncrement(_configuration["RestHostSettings:Host"].ToString(), MetricCounter.SuccessCommitCounter); } else { Task.Run(() => _logProvider.PublishInfo("GONOrderingSystems.Services.Order", "Fail to Commit " + JsonConvert.SerializeObject(orderValue))); _metricsProvider.RestCounterIncrement(_configuration["RestHostSettings:Host"].ToString(), MetricCounter.FailedCommitCounter); } var committedOffsets = consumer.CommitAsync(msg).Result; } } } catch (Exception ex) { Task.Run(() => _logProvider.PublishError("GONOrderingSystems.Services.Order", "Error on Commit " + JsonConvert.SerializeObject(orderValue), ex)); } } } }