private static void prepareQueue(string queue, string routing_key, IClientSession session) { // Create a unique queue name for this consumer by concatenating // the queue name parameter with the Session ID. Console.WriteLine("Declaring queue: " + queue); session.QueueDeclare(queue, Option.EXCLUSIVE, Option.AUTO_DELETE); // Route messages to the new queue if they match the routing key. // Also route any messages to with the "control" routing key to // this queue so we know when it's time to stop. A publisher sends // a message with the content "That's all, Folks!", using the // "control" routing key, when it is finished. session.ExchangeBind(queue, "amq.topic", routing_key); session.ExchangeBind(queue, "amq.topic", "control"); // subscribe the listener to the queue IMessageListener listener = new MessageListener(session); session.AttachMessageListener(listener, queue); session.MessageSubscribe(queue); }