Example #1
0
        private static async Task AddStockProxy(string productName, int quantity)
        {
            var message = new ProductStockEvent()
            {
                Action      = StockAction.Add,
                ProductName = productName,
                Quantity    = quantity
            };


            var stringTask = await client.PostAsJsonAsync("https://localhost:44371/api/Inventory", message);
        }
Example #2
0
        public async Task Post([FromBody] ProductStockEvent value)
        {
            var config = new ProducerConfig {
                BootstrapServers = "127.0.0.1:9092"
            };

            using (var producer = new Producer <string, string>(config))
            {
                var deliveryReport = await producer.ProduceAsync(TOPICS.INVENTORYEVENTS, new Message <string, string>
                {
                    Key   = value.ProductName,
                    Value = JsonConvert.SerializeObject(value)
                });
            }
        }