I use the following code to publish a raw message to the queue:
using (var bus = RabbitHutch.CreateBus("host=myserver;virtualHost=myhost;username=xxx;password=yyy").Advanced)
{
var queue = bus.QueueDeclare("MyQueue");
var exchange = bus.ExchangeDeclare("MyExchange", ExchangeType.Topic);
var binding = bus.Bind(exchange, queue, "");
var properties = new MessageProperties();
var body = System.Text.Encoding.UTF8.GetBytes("This is the body of the message");
bus.Publish(exchange, "", false, false, properties, body);
}
The message got delivered to the queue and I see one message in the queue from RabbitMQ's console. However, when I try to consume it with the following code I'm not getting anything back:
bus.Consume(queue, (body, properties, info) => Task.Factory.StartNew(() =>
{
var message = Encoding.UTF8.GetString(body);
Console.Out.WriteLine("Got message: '{0}'", message);
}));
I can see the message is delivered from Rabbit's console but nothing gets printed out and the message is still in the queue. What am I missing?