25 lines
743 B
C#
25 lines
743 B
C#
using RabbitMQ.Client;
|
|
using System.Text;
|
|
|
|
var factory = new ConnectionFactory() { HostName = "localhost:7003" };
|
|
using (var connection = factory.CreateConnection())
|
|
using (var channel = connection.CreateModel())
|
|
{
|
|
channel.QueueDeclare(queue: "",
|
|
durable: false,
|
|
exclusive: false,
|
|
autoDelete: false,
|
|
arguments: null);
|
|
|
|
while (true)
|
|
{
|
|
Console.WriteLine("Enter your message:");
|
|
string message = Console.ReadLine();
|
|
|
|
var body = Encoding.UTF8.GetBytes(message);
|
|
|
|
channel.BasicPublish(exchange: "hello",
|
|
body: body);
|
|
Console.WriteLine("Sent {0}", message);
|
|
}
|
|
} |