<pre> public static void Main() { Console.WriteLine("message from NewMethod:" + NewMethod()); Console.ReadLine(); } static string NewMethod() { string message = string.Empty; var factory = new ConnectionFactory() { HostName = "localhost" }; using (var connection = factory.CreateConnection()) using (var channel = connection.CreateModel()) { channel.QueueDeclare(queue: "hello", durable: false, exclusive: false, autoDelete: false, arguments: null); var consumer = new EventingBasicConsumer(channel); consumer.Received += (model, ea) => { var body = ea.Body; message = Encoding.UTF8.GetString(body); Console.WriteLine("[x] Received {0}", message); }; channel.BasicConsume(queue: "hello", noAck: true, consumer: consumer); } return message; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)