Reformatted and cleaned up
This commit is contained in:
parent
870b674a05
commit
e72593af4f
@ -1,17 +1,20 @@
|
|||||||
using System;
|
using System;
|
||||||
using RabbitMQ.Client;
|
using RabbitMQ.Client;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
class EmitLog {
|
class EmitLog
|
||||||
public static void Main(string[] args) {
|
{
|
||||||
ConnectionFactory factory = new ConnectionFactory();
|
public static void Main(string[] args)
|
||||||
factory.HostName = "localhost";
|
{
|
||||||
using (IConnection connection = factory.CreateConnection())
|
var factory = new ConnectionFactory() { HostName = "localhost" };
|
||||||
using (IModel channel = connection.CreateModel()) {
|
using (var connection = factory.CreateConnection())
|
||||||
|
using (var channel = connection.CreateModel())
|
||||||
|
{
|
||||||
channel.ExchangeDeclare("logs", "fanout");
|
channel.ExchangeDeclare("logs", "fanout");
|
||||||
|
|
||||||
string message = (args.Length > 0) ? string.Join(" ", args)
|
var message = (args.Length > 0) ? string.Join(" ", args)
|
||||||
: "info: Hello World!";
|
: "info: Hello World!";
|
||||||
byte[] body = System.Text.Encoding.UTF8.GetBytes(message);
|
var body = Encoding.UTF8.GetBytes(message);
|
||||||
channel.BasicPublish("logs", "", null, body);
|
channel.BasicPublish("logs", "", null, body);
|
||||||
Console.WriteLine(" [x] Sent {0}", message);
|
Console.WriteLine(" [x] Sent {0}", message);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user