public bool HandleInventoryReservedEvent(InventoryReservedEvent evt)
        {
            Console.WriteLine($"Handling inventory reserved event - {evt.EventId}");
            ProductActivity activity = new ProductActivity
            {
                OrderId      = evt.OrderId,
                SKU          = evt.SKU,
                Quantity     = (int)evt.Quantity,
                ActivityId   = evt.EventId,
                CreatedOn    = DateTime.UtcNow.Ticks,
                ActivityType = Entities.ActivityType.Reserved
            };
            var result = this.repository.PutActivity(activity);

            return(result != null);
        }
        public void Consume()
        {
            Task.Run(() =>
            {
                Console.WriteLine($"Starting Kafka subscription to {topic}");
                using (var consumer = new Consumer <Null, string>(config, null, new StringDeserializer(Encoding.UTF8)))
                {
                    //consumer.Assign(new List<TopicPartitionOffset> { new TopicPartitionOffset(topic, 0, 0) });
                    consumer.Subscribe(new[] { topic });

                    while (true)
                    {
                        Message <Null, string> msg;
                        if (consumer.Consume(out msg, TimeSpan.FromSeconds(1)))
                        {
                            string rawJson = msg.Value;
                            try
                            {
                                InventoryReservedEvent evt = JsonConvert.DeserializeObject <InventoryReservedEvent>(rawJson);
                                eventProcessor.HandleInventoryReservedEvent(evt);
                                var committedOffsets = consumer.CommitAsync(msg).Result;
                                if (committedOffsets.Error.HasError)
                                {
                                    Console.WriteLine($"Failed to commit offsets : {committedOffsets.Error.Reason}");
                                }
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.StackTrace);
                                Console.WriteLine($"Failed to handle inventory reserved event : ${ex.ToString()}");
                            }
                        }
                    }
                }
            });
        }