[rabbitmq-discuss] queueDeclarePassive Shutting down the channel

Alexandru Scvorţov alexandru at rabbitmq.com
Sun Feb 13 01:49:43 GMT 2011


Hi Max,

Attempting to declare a non existent queue (even if you do so passively)
causes a not-found exception, which is a soft-error that takes down the
channel.

If you really want to use *declarePassive, you should wrap it in a
try...catch and handle the exception somehow.

As a rule, you shouldn't need to use *declarePassive.  The *declare
operations are idempotent, so you'd normally just declare the resource
before using it (i.e. open channel, declare the queue, publish to it,
close channel).

Cheers,
Alex

On Sat, Feb 12, 2011 at 08:30:48PM -0500, Max Bridgewater wrote:
> Hi,
> 
> I'm using the Java client and I notice that  queueDeclarePassive()
> shuts down the channel if no queue exists with the specified name. I'm
> not sure if I'm doing something wrong or this is how this is supposed
> to behave. Here is my code; please advise.
> 
> public class QueuePassiveDeclare {
> 	
> 	public static void main(String[] argv) throws Exception {
> 		String host = "localhost";
> 		String vhost = "MyVHost";
> 		String user = "guest";
> 		String name = "myQueue";
> 
> 		ConnectionFactory factory = new ConnectionFactory();
> 		factory.setHost(host);
> 		factory.setPassword(user);
> 		factory.setUsername(user);
> 		factory.setVirtualHost(vhost);
> 		Connection conn = factory.newConnection();
> 		Channel chan = conn.createChannel();
> 		chan.queueDeclarePassive(name);
> 
> 	}
> }
> 
> Thanks,
> Max.
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss


More information about the rabbitmq-discuss mailing list