Exemplo n.º 1
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            Console.WriteLine($"Decorator service is running at: {DateTime.Now}");

            while (!stoppingToken.IsCancellationRequested)
            {
                var allConnections = new Dictionary <string, IConsumer <string, string> >(SignalRKafkaProxy.AllConsumers);
                Console.WriteLine("Connections count:" + allConnections.Count);
                foreach (var c in allConnections)
                {
                    Console.WriteLine("ConnectionId: " + c.Key);
                }

                if (allConnections != null)
                {
                    foreach (var connection in allConnections)
                    {
                        //Read a message
                        string connectionId = connection.Key;
                        Console.WriteLine($"connection: {connectionId}, consumer:{connection.Value}");
                        IConsumer <string, string> consumerConnection = connection.Value;

                        var consumerResult = consumerConnection.Consume(new TimeSpan(0, 0, 15));

                        if (consumerResult != null)
                        {
                            //Deserilaize
                            BakedOrder orderRequest = JsonConvert.DeserializeObject <BakedOrder>(consumerResult.Value);
                            Console.WriteLine($"Info: Recieved order to mix. Id# {orderRequest.Id}");

                            //Step 1: If there is a new message in KAFKA "Orders" topic, inform the client.
                            Console.WriteLine($"Informing UI connected clients about the newly recieved order. Id# {orderRequest.Id}");

                            await _orderMonitorHub.Clients.Client(connectionId).InformNewOrderToDecorate(orderRequest);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
 public MarkOrderStatusAsBakedCommand(BakedOrder order)
 {
     this.Order = order;
 }
 public CupcakeOrderBakedEvent(BakedOrder order)
 {
     this.Order = order;
 }