[rabbitmq-discuss] Trying to handle ConnectionShutdown event

Bernhard Mogens Ege bme at saseco.dk
Wed Nov 28 12:48:48 GMT 2012


I am trying to handle the ConnectionShutdown event by recreating all my subscriptions once the broker is up again. I do get the exception when the broker dies and when it comes back up, I try to re-subscribe to my subscriptions. But this is where I run into problems.

My subscriptions are originally created like this:

                string queueName = channel.QueueDeclare();
                EventingBasicConsumer consumer = new EventingBasicConsumer();
                consumer.Received += e;
                string consumerTag = channel.BasicConsume(queueName, true, consumer);
                channel.QueueBind(queueName, ExchangeName, routingKey, arguments);
                subscriptions.Add(new Subscription(queueName, routingKey, e, arguments));
               return queueName;

When I resubscribe, I do it like this:

                        channel.QueueDeclare(subscription.queueName,
                                             false,     // durable
                                             true,      // exclusive
                                             true,      // autodelete
                                             subscription.args);
                        EventingBasicConsumer consumer = new EventingBasicConsumer();
                        consumer.Received += subscription.e;
                        string consumerTag = channel.BasicConsume(subscription.queueName, true, consumer);
                        channel.QueueBind(subscription.queueName, ExchangeName, subscription.routingKey, subscription.args);

But this fails as I am not allowed to call QueueDeclare with the originally returned queueName. It looks like this: "amq.gen-g9hUDvDfwwO4YvlhRsGaZj".

I take it RabbitMQ/AMQP does not allow one to recreate queues with such autogenerated names. Do I have to make my own random name generator for queues in order to allow for recreation of queues (or use predefined static queuenames)?

Thanks,

Bernhard

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20121128/2d767328/attachment.htm>


More information about the rabbitmq-discuss mailing list