예제 #1
0
        private static void Main()
        {
            var factory = new ConnectionFactory()
            {
                HostName = "localhost"
            };

            using (var connection = factory.CreateConnection())
            {
                using (var channel = connection.CreateModel())
                {
                    Console.WriteLine("Fill Running");
                    while (connection.IsOpen)
                    {
                        while (channel.MessageCount("sport_events") > 100)
                        {
                            Thread.Sleep(1000);
                        }
                        var publishSportEvent = SportEvent.GenerateEvent();
                        channel.BasicPublish(
                            exchange: "",
                            routingKey: "sport_events",
                            basicProperties: null,
                            body: publishSportEvent.ToBytes());
                        Console.WriteLine(new string('-', 30) + "\n" + publishSportEvent);
                        Thread.Sleep(100);
                    }
                    Console.WriteLine("Fill Stopped");
                }
            }
        }
예제 #2
0
 public static SportEvent GenerateEvent()
 {
     return new SportEvent(
         s_random.Next(1,100),
         s_random.Next(1,4),
         SportEvent.GenerateEventName(),
         DateTime.Now,
         RandomDouble,
         RandomDouble,
         RandomDouble);
 }