using System.Text; using RabbitMQ.Client; var factory = new ConnectionFactory { HostName = "localhost" }; using var connection = factory.CreateConnection(); using var channel = connection.CreateModel(); channel.ExchangeDeclare(exchange: "reports", type: ExchangeType.Fanout); Random rand = new Random(); foreach (var item in Enumerable.Range(0, 1000)) { var message = $"Необходимо создать отчет #{rand.Next()}"; var body = Encoding.UTF8.GetBytes(message); channel.BasicPublish(exchange: "reports", routingKey: string.Empty, basicProperties: null, body: body); Console.WriteLine($" [x] Поступила работа {message}"); await Task.Delay(1000); } Console.WriteLine(" Press [enter] to exit."); Console.ReadLine();