[rabbitmq-discuss] immediate, mandatory flag with no consumers

cogitate monish.unni at gmail.com
Wed Apr 25 20:27:41 BST 2012

i am trying to understand the usage of "immediate" and "mandatory" vis-
a-vis when there are no consumers, to get rabbitmq broker to call
handleReturn callback, after i setup returnListener.

i ran through the following scenarios:
1. no exchange, no queue
2. exchange, no queue
3. exchange, queue - no consumers
but, i don't get a return call from the server.

following pseudo code/ fragment is what i use:
//setup queue
 boolean durable = false;
 boolean autoDelete = true;
 boolean exclusive = false;
 try {
   } catch (IOException e) {}

//setup consumer:
consumer = new QueueingConsumer(channel);
 try {
 } catch (IOException e) {}

//setup listener:
channel.addReturnListener(new ReturnListener() {
            public void handleReturn(int replyCode, String replyText,
String exchange, String routingKey, AMQP.BasicProperties properties,
byte[] body) throws IOException {
                log("[ERROR:Service :"+routingKey+" seems down,
returning with code="+replyCode+" message="+replyText+"]");

//publish message:
// using BasicProperties.Builder, i add a replyTo= REPLY_QUEUE
// props represents an instance of AMQP.BasicProperties w/ replyTo set
boolean mandatory=true;
boolean immediate=true;
channel.basicPublish(exchange, routingKey, mandatory,

any help in understanding is much appreciated.
i have gone through these posts :
* http://groups.google.com/group/rabbitmq-discuss/browse_thread/thread/5490be59d478f88/52ee9568d07441a6?lnk=gst&q=immediate#52ee9568d07441a6
the second throws some light on use case 2. the first link, is quite
enlightening but, since it was a thread in 2010, wondering if it's
status quo.

thanks and regards,

More information about the rabbitmq-discuss mailing list