
* Specify unix line endings so that `christian-bromann/docusaurus-theme-github-codeblock` formats code blocks correctly * Fix RPC examples
18 lines
725 B
C#
18 lines
725 B
C#
using RabbitMQ.Client;
|
|
using System.Text;
|
|
|
|
var factory = new ConnectionFactory { HostName = "localhost" };
|
|
using var connection = await factory.CreateConnectionAsync();
|
|
using var channel = await connection.CreateChannelAsync();
|
|
|
|
await channel.ExchangeDeclareAsync(exchange: "direct_logs", type: ExchangeType.Direct);
|
|
|
|
var severity = (args.Length > 0) ? args[0] : "info";
|
|
var message = (args.Length > 1) ? string.Join(" ", args.Skip(1).ToArray()) : "Hello World!";
|
|
var body = Encoding.UTF8.GetBytes(message);
|
|
await channel.BasicPublishAsync(exchange: "direct_logs", routingKey: severity, body: body);
|
|
Console.WriteLine($" [x] Sent '{severity}':'{message}'");
|
|
|
|
Console.WriteLine(" Press [enter] to exit.");
|
|
Console.ReadLine();
|