forked from Alexey/DAS_2024_1
41 lines
1.2 KiB
C#
41 lines
1.2 KiB
C#
|
using Publisher;
|
|||
|
using System.Text;
|
|||
|
|
|||
|
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 sender = new Sender(rabbitHost, rabbitUsername, rabbitPassword);
|
|||
|
|
|||
|
sender.AddExcange(rabbitExchange);
|
|||
|
|
|||
|
var rnd = new Random();
|
|||
|
|
|||
|
while (true)
|
|||
|
{
|
|||
|
StringBuilder sb = new();
|
|||
|
|
|||
|
var type = rnd.Next();
|
|||
|
switch (type%2)
|
|||
|
{
|
|||
|
case 0:
|
|||
|
{
|
|||
|
sb.Append($"Был запрошен отчет о данных под номером {rnd.Next(1000)}");
|
|||
|
break;
|
|||
|
}
|
|||
|
case 1:
|
|||
|
{
|
|||
|
sb.Append($"Был запрошен отчет об ошибках под номером {rnd.Next(1000)}");
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
var text = sb.ToString();
|
|||
|
Console.WriteLine($"Было опубликовано сообщение: {text}");
|
|||
|
sender.PublishToExchange(rabbitExchange, text);
|
|||
|
|
|||
|
await Task.Delay(1000);
|
|||
|
}
|
|||
|
|