DAS_2024_1/dozorova_alena_lab_4/ConsumerDelay/Program.cs

24 lines
860 B
C#

using ConsumerDelay;
var rabbitHost = Environment.GetEnvironmentVariable("RABBIT_HOST") ?? "localhost";
var rabbitUsername = Environment.GetEnvironmentVariable("RABBIT_USERNAME") ?? "user";
var rabbitPassword = Environment.GetEnvironmentVariable("RABBIT_PASSWORD") ?? "password";
var rabbitExchange = Environment.GetEnvironmentVariable("RABBIT_EXCHANGE") ?? "ReportIn";
var rabbitQueue = Environment.GetEnvironmentVariable("RABBIT_QUEUE") ?? "Second";
Thread.Sleep(2000);
var receiver = new Receiver(rabbitHost, rabbitUsername, rabbitPassword);
receiver.SubscribeTo(rabbitExchange, (message) =>
{
var rnd = new Random();
Console.WriteLine($"Пришло сообщение: {message}");
Thread.Sleep(rnd.Next(2000, 3000));
Console.WriteLine($"Обработка сообщения завершена");
},
rabbitQueue);
while (true) ;