Example #1
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            Console.WriteLine($"Box service is running at: {DateTime.Now}");

            while (!stoppingToken.IsCancellationRequested)
            {
                var allConnections = new Dictionary <string, Consumer <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}");
                        Consumer <string, string> consumerConnection = connection.Value;

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

                        if (consumerResult != null)
                        {
                            //Deserilaize
                            DecoratedOrder orderRequest = JsonConvert.DeserializeObject <DecoratedOrder>(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).InformNewOrderToPackage(orderRequest);
                        }
                    }
                }
            }
        }
Example #2
0
 public CupcakeOrderDecoratedEvent(DecoratedOrder order)
 {
     this.Order = order;
 }
 public MarkOrderStatusAsDecoratedCommand(DecoratedOrder order)
 {
     this.Order = order;
 }