예제 #1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            try
            {
                base.OnStartup(e);
                var factory = new ConnectionFactory()
                {
                    HostName = "localhost"
                };
                Connection = factory.CreateConnection();
                Channel    = Connection.CreateModel();

                var messageBusClient = new MessageBusPublisherClient(Channel, ExchangeName);

                MainWindow = new MainWindow();
                MainViewModel mainViewModel = new MainViewModel(messageBusClient);
                MainWindow.DataContext = mainViewModel;
                MainWindow.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show($"An error occurred while starting up the application. {ex.Message}");
                Shutdown();
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            string exchangeName = "queueLink";

            ConnectionFactory factory = new ConnectionFactory()
            {
                HostName = "localhost",
                UserName = "******",
                Password = "******"
            };

            using var connection = factory.CreateConnection();
            using var channel    = connection.CreateModel();
            {
                MessageBusPublisherClient publisher = new MessageBusPublisherClient(channel, exchangeName);

                string exitCode = "";
                while (exitCode != "-1")
                {
                    string id = "";
                    Console.WriteLine("Enter download ID");
                    id = Console.ReadLine().ToLower();

                    var updateMessage = new UpdateInformation
                    {
                        DownloadEndPoint    = @$ "http://*****:*****@$ "http://localhost:57308/updates/{id}/information",
                        Id = id
                    };

                    Message <UpdateInformation> message = new Message <UpdateInformation>(Guid.NewGuid(), updateMessage);

                    publisher.PostAsync(message);
                    Console.WriteLine($"Message Send :: {message.Body}\n\n");
                }
            }
        }