// ReSharper disable once UnusedMethodReturnValue.Global public async Task <Passenger> Create(Passenger passenger) { passenger.Enabled = true; _passengers.InsertOne(passenger); await _producer.WriteMessage(_kafkaTopics.Create, JsonConvert.SerializeObject(passenger)); return(passenger); }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { Console.WriteLine("OrderProcessing Service Started"); while (!stoppingToken.IsCancellationRequested) { var consumerHelper = new ConsumerWrapper(consumerConfig, "orderrequests"); string orderRequest = consumerHelper.ReadMessage(); if (string.IsNullOrWhiteSpace(orderRequest)) { Console.WriteLine("No message available!"); return; } //Deserilaize OrderRequest order = JsonConvert.DeserializeObject <OrderRequest>(orderRequest); if (order == null) { Console.WriteLine("Order details not available!"); return; } //TODO:: Process Order Console.WriteLine($"Info: OrderHandler => Processing the order for {order.productname}"); order.status = OrderStatus.COMPLETED; //Write to ReadyToShip Queue var producerWrapper = new ProducerWrapper(producerConfig, "readytoship"); await producerWrapper.WriteMessage(JsonConvert.SerializeObject(order)); } }
public async Task <ActionResult <User> > Post([FromBody] User User) { User.Id = await this._userrepo.GetNextId(); var producer = new ProducerWrapper(this._producerConfig, "testtopic"); string jsondata = JsonConvert.SerializeObject(User); await producer.WriteMessage(jsondata); await _userrepo.Create(User); return(new OkObjectResult(User)); }
public async Task <ActionResult> PostAsync([FromBody] OrderRequest value) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } //Serialize string serializedOrder = JsonConvert.SerializeObject(value); Console.WriteLine("========"); Console.WriteLine("Info: OrderController => Post => Received a new purchase order:"); Console.WriteLine(serializedOrder); Console.WriteLine("========="); var producer = new ProducerWrapper(config, "orderrequests"); await producer.WriteMessage(serializedOrder); return(Created("TransactionId", "Your order is in progress")); }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { Console.WriteLine("OrderProcessing Service Started"); while (!stoppingToken.IsCancellationRequested) { var consumerHelper = new ConsumerWrapper(consumerConfig, "orderrequests"); string orderRequest = consumerHelper.ReadMessage(); //Deserialize OrderRequest order = JsonConvert.DeserializeObject <OrderRequest>(orderRequest); //TODO:: Process Order Console.WriteLine($"Info: OrderHandler => Processing the order for {order.ProductName}"); order.Status = OrderStatus.Completed; //Write to ReadyToShip Queue var producerWrapper = new ProducerWrapper(producerConfig, "readytoship"); await producerWrapper.WriteMessage(JsonConvert.SerializeObject(order)); } }
public async Task WriteAsync(Reservation reservation) { await _producer.WriteMessage(reservation); }
public async Task WriteAsync(Reservation reservation) { // What if the kafka server is down? await _producer.WriteMessage(reservation); }