21 lines
596 B
C#
21 lines
596 B
C#
|
using System.Text;
|
|||
|
using RabbitMQ.Client;
|
|||
|
|
|||
|
var factory = new ConnectionFactory { HostName = "localhost" };
|
|||
|
using var connection = factory.CreateConnection();
|
|||
|
using var channel = connection.CreateModel();
|
|||
|
|
|||
|
channel.ExchangeDeclare("reports", ExchangeType.Fanout);
|
|||
|
|
|||
|
var rand = new Random();
|
|||
|
|
|||
|
while (true)
|
|||
|
{
|
|||
|
var message = $"Необходимо создать отчет #{rand.Next()}";
|
|||
|
var body = Encoding.UTF8.GetBytes(message);
|
|||
|
|
|||
|
channel.BasicPublish("reports", string.Empty, null, body);
|
|||
|
Console.WriteLine($" [x] Отправлено \"{message}\"");
|
|||
|
|
|||
|
Thread.Sleep(1000);
|
|||
|
}
|