I implement a simple client to RabbitMQ, using EasyNetQ. After a connection, I get a notification "Model shutdown for queue". Here is my code:
var _bus = RabbitHutch.CreateBus(String.Format("host={0}", hostName)).Advanced;
var _exchange = Exchange.DeclareFanout(exName);
var _queue = Queue.DeclareTransient();
_queue.BindTo(_exchange, "_");
_bus.Subscribe(
_queue,
(msg, properties, messageReceivedInfo) =>
{
return Task.Factory.StartNew(() =>
{
Console.WriteLine(msg.Length.ToString());
});
});
Using more low-level approach, everything works great (the message length is displayed in the console):
var factory = new ConnectionFactory();
factory.HostName = hostName;
var connect = factory.CreateConnection();
var channel = connect.CreateModel();
channel.ExchangeDeclare(exName, "fanout");
var resultQueue = channel.QueueDeclare(string.Empty, false, true, false, null);
string queueName = resultQueue.QueueName;
var consumer = new QueueingBasicConsumer(channel);
channel.QueueBind(queueName, exName, string.Empty);
var resultConsume = channel.BasicConsume(queueName, false, consumer);
while(true)
{
var e = (BasicDeliverEventArgs)consumer.Queue.Dequeue();
Console.WriteLine(e.Body.Length.ToString());
channel.BasicAck(e.DeliveryTag, false);
}
Please, prompt, what's wrong in the first approach?
UPD I caught Exception with IntelliTrace :
The AMQP operation was interrupted: AMQP close-reason, initiated by Peer, code=406, text="PRECONDITION_FAILED - cannot redeclare exchange 'live' in vhost '/' with different type, durable, internal or autodelete value", classId=40, methodId=10, cause=
Exchange settings are the same (see above). So what's wrong?