Exemplo n.º 1
0
        static void Main(string[] args)
        {
            try
            {
                if (args.Select(s => s.ToLower()).Contains("kafka"))
                {
                    //TODO: KafkaSettings
                    producer = new KafkaProducer();
                }
                else
                {
                    RabbitMQSettings settings = (RabbitMQSettings)ConfigurationManager.GetSection("rabbitMQSettings");
                    producer = new RabbitMQProducer(settings);
                }
                producer.Initialize();
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.Message);
                producer?.Dispose();
                System.Console.Read();
                return;
            }

            System.Console.WriteLine("For exit enter \"X\"");
            System.Console.WriteLine("Enter count random messages");

            Sending();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            System.Console.WriteLine("Select a broker: \"R\" - RabbitMQ, \"K\" - Kafka");
            string choice = System.Console.ReadLine();

            while (choice != "R" && choice != "K")
            {
                System.Console.WriteLine("Try again");
                choice = System.Console.ReadLine();
            }

            try
            {
                if (choice == "K")
                {
                    //TODO: KafkaSettings
                    producer = new KafkaProducer();
                }
                else
                {
                    RabbitMQSettings settings = (RabbitMQSettings)ConfigurationManager.GetSection("rabbitMQSettings");
                    producer = new RabbitMQProducer(settings);
                }
                producer.Initialize();
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.Message);
                producer?.Dispose();
                System.Console.Read();
                return;
            }

            System.Console.WriteLine("For exit enter \"X\"");
            System.Console.WriteLine("Enter count random messages");


            Sending();
        }