static void Main(string[] args)
        {
            Console.WriteLine("Starting RabbitMQ Message Publisher");
            Console.WriteLine();
            Console.WriteLine();

            var messageCount = 0;
            var publisher    = new RabbitPublisher();

            Console.WriteLine("Enter key to publish a message.");

            while (true)
            {
                var key = Console.ReadKey();
                if (key.Key == ConsoleKey.Q)
                {
                    break;
                }

                if (key.Key == ConsoleKey.Enter)
                {
                    var routingKey = GetRoutingKey(messageCount);

                    var message = $"Message: {messageCount}";
                    Console.WriteLine("Sending: {0} - Routing Key: {1}", messageCount, routingKey);

                    publisher.PublishMessage(message, routingKey);

                    messageCount++;
                }
            }

            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Starting RabbitMQ Message Publisher");
            Console.WriteLine();
            Console.WriteLine();

            var messageCount = 0;
            var publisher    = new RabbitPublisher();

            Console.WriteLine("Enter key to publish a message.");

            while (true)
            {
                var key = Console.ReadKey();
                if (key.Key == ConsoleKey.Q)
                {
                    break;
                }

                if (key.Key == ConsoleKey.Enter)
                {
                    var message = $"Message: {messageCount}";

                    publisher.PublishMessage(message, GetDictionary(messageCount));

                    messageCount++;
                }
            }

            Console.ReadLine();
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Starting RabbitMQ Message Publisher");
            Console.WriteLine();
            Console.WriteLine();

            var messageCount = 0;
            var publisher    = new RabbitPublisher();

            Console.WriteLine("Enter a number 1-6 then press enter key to send a message.");
            int messageNumber = 0;

            while (true)
            {
                var key = Console.ReadKey();

                ProcessKeyStroke(ref messageNumber, ref key);

                if (key.Key.Equals(ConsoleKey.Enter))
                {
                    if (messageNumber == 0)
                    {
                        Console.WriteLine("Please supply a number from 1 - 6 and press enter key.");
                        continue;
                    }

                    var message = $"Message ID: {messageCount}";
                    Console.WriteLine("Sending - {0}", message);

                    var responses = publisher.PublishMessage(message, messageNumber.ToString(), new TimeSpan(0, 0, 0, 0, 400), 3);

                    Console.WriteLine();
                    Console.WriteLine("{0} replies recivied", responses.Count);
                    Console.WriteLine();
                    Console.WriteLine("Listing responses.");
                    foreach (var response in responses)
                    {
                        Console.WriteLine("Response - {0}", response);
                    }

                    Console.WriteLine();
                    Console.WriteLine();
                    Console.WriteLine("Please supply a number from 1 - 6 and press enter key.");

                    messageCount++;
                }
            }
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Starting RabbitMQ Message Publisher");
            Console.WriteLine();
            Console.WriteLine();

            var messageCount = 0;
            var publisher    = new RabbitPublisher();

            Console.WriteLine("Enter key to publish a message.");

            while (true)
            {
                var key = Console.ReadKey();
                if (key.Key == ConsoleKey.Q)
                {
                    break;
                }

                if (key.Key != ConsoleKey.Enter)
                {
                    continue;
                }

                var message = $"Message: {messageCount}";

                Console.WriteLine("Sending - {0}", messageCount);

                var response = publisher.PublishMessage(message, new TimeSpan(0, 0, 3, 0));

                Console.WriteLine("Response - {0}", response);

                messageCount++;
            }

            Console.ReadLine();
        }