[rabbitmq-discuss] RabbitMQ New Queues are not getting binded to the newly created exchange.

k.madnani84 k.madnani84 at gmail.com
Mon Aug 12 05:44:09 BST 2013


Hi,

I am using a java client in order to create a new exchange and a new queue
and to bind them and publish message on the exchange.The Exchange is of type
fan out so that whatever messages i publish to it should go to all the
queues bound to it.The queues are automatically generated with the API
queueDeclare.After running the below program i could see the exchange
getting created but no queues are bound it.I couldnt see my newly created
queue in the queue list.
I ran "rabbitmqctl list_bindings" but couldnt find any entry for it.Could
anybody help on it?

Java Code:
private static final String EXCHANGE_NAME = "logs5";
ConnectionFactory factory = new ConnectionFactory();
		factory.setHost("localhost");
		factory.setPort(5691);
		factory.setUsername("rbtadmin");
		factory.setPassword("x5b:LszV");
		
		try {
			Connection connection = factory.newConnection();
			Channel channel = connection.createChannel();
			
			channel.exchangeDeclare(EXCHANGE_NAME, "fanout");
			
			String queueName=channel.queueDeclare().getQueue();
			System.out.println("Queue Generated " + queueName);
			BindOk isBindOk=channel.queueBind(queueName, "logs5", "");
			
			System.out.println(" Queue Bind'" + isBindOk.toString());
			
			String message = "Hello World !!!";
			
			channel.basicPublish(EXCHANGE_NAME, "", null, message.getBytes());
		    System.out.println(" [x] Sent '" + message + "'");

		    channel.close();
		    connection.close();
		} catch (IOException e) {
			
			e.printStackTrace();
		}
	    
Output:
Queue Generated amq.gen-E-JlumgQ_lbzAo7tlojrog
 Queue Bind'#method<queue.bind-ok>()
 [x] Sent 'Hello World !!!'
	      



--
View this message in context: http://rabbitmq.1065348.n5.nabble.com/RabbitMQ-New-Queues-are-not-getting-binded-to-the-newly-created-exchange-tp28718.html
Sent from the RabbitMQ mailing list archive at Nabble.com.


More information about the rabbitmq-discuss mailing list