Ejemplo n.º 1
0
        public GreetingServer()
        {
            var configurations = AppSettings.RabbitMqConfigurations;

            log.Info("register consumer");
            bus = BusCreator.Create(configurations, (cfg, host) =>
            {
                cfg.ReceiveEndpoint(host, configurations.WindowsServiceQueue, e =>
                {
                    e.Consumer <WindowsServiceConsumer>();
                });
            });
        }
        static void Main(string[] args)
        {
            var configurations = AppSettings.RabbitMqConfigurations;
            var bus            = BusCreator.Create(configurations);
            var sendToUri      = new Uri($"{configurations.Uri}{configurations.WindowsServiceQueue}");

            var text = string.Empty;

            while (text != "quit")
            {
                Console.Write("Enter a message: ");
                text = Console.ReadLine();

                var message = new WindowsServiceCommand
                {
                    Id       = Guid.NewGuid(),
                    Message  = text,
                    DateTime = DateTime.Now
                };

                Task.Run(() => CommandExtension.SendCommand(bus, sendToUri, message));
            }
        }