public async Task Handle(JObject jObject, ILog log, CancellationToken cancellationToken) { try { bool orderIsValid = true; string message = null; log.Info("Consume OrderCreatedEvent"); var dataConsomed = jObject.ToObject <OrderCreatedEvent>(); var allProduct = dataConsomed.OrderItems .Select(x => x.PartNumber) .ToList(); //Consume data and validate the data allProduct.ForEach(async item => { var dataIsExist = await _productQueries.GetProductByPartNumber(item); if (dataIsExist == null) { orderIsValid = false; } }); if (orderIsValid == false) { message = "Customer not found"; } var @event = new OrderValidatedEvent { OrderId = dataConsomed.OrderId, IsValid = orderIsValid, Messages = new List <string> { message } }; await _producer.Send(@event, "PosServices"); } catch (Exception ex) { log.Error("Error Validating order by product", ex); throw ex; } }