<div dir="ltr"><div>The queueDeclare() method (with no arguments) creates an exclusive auto-delete queue, so as soon as you do the channel.close() the queue will get deleted. You might want to look at using one of the other queueDeclare() methods to create a non-auto-delete queue.<br>
<br></div>Brett<br><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Aug 12, 2013 at 4:44 PM, k.madnani84 <span dir="ltr"><<a href="mailto:k.madnani84@gmail.com" target="_blank">k.madnani84@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I am using a java client in order to create a new exchange and a new queue<br>
and to bind them and publish message on the exchange.The Exchange is of type<br>
fan out so that whatever messages i publish to it should go to all the<br>
queues bound to it.The queues are automatically generated with the API<br>
queueDeclare.After running the below program i could see the exchange<br>
getting created but no queues are bound it.I couldnt see my newly created<br>
queue in the queue list.<br>
I ran "rabbitmqctl list_bindings" but couldnt find any entry for it.Could<br>
anybody help on it?<br>
<br>
Java Code:<br>
private static final String EXCHANGE_NAME = "logs5";<br>
ConnectionFactory factory = new ConnectionFactory();<br>
factory.setHost("localhost");<br>
factory.setPort(5691);<br>
factory.setUsername("rbtadmin");<br>
factory.setPassword("x5b:LszV");<br>
<br>
try {<br>
Connection connection = factory.newConnection();<br>
Channel channel = connection.createChannel();<br>
<br>
channel.exchangeDeclare(EXCHANGE_NAME, "fanout");<br>
<br>
String queueName=channel.queueDeclare().getQueue();<br>
System.out.println("Queue Generated " + queueName);<br>
BindOk isBindOk=channel.queueBind(queueName, "logs5", "");<br>
<br>
System.out.println(" Queue Bind'" + isBindOk.toString());<br>
<br>
String message = "Hello World !!!";<br>
<br>
channel.basicPublish(EXCHANGE_NAME, "", null, message.getBytes());<br>
System.out.println(" [x] Sent '" + message + "'");<br>
<br>
channel.close();<br>
connection.close();<br>
} catch (IOException e) {<br>
<br>
e.printStackTrace();<br>
}<br>
<br>
Output:<br>
Queue Generated amq.gen-E-JlumgQ_lbzAo7tlojrog<br>
Queue Bind'#method<queue.bind-ok>()<br>
[x] Sent 'Hello World !!!'<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://rabbitmq.1065348.n5.nabble.com/RabbitMQ-New-Queues-are-not-getting-binded-to-the-newly-created-exchange-tp28718.html" target="_blank">http://rabbitmq.1065348.n5.nabble.com/RabbitMQ-New-Queues-are-not-getting-binded-to-the-newly-created-exchange-tp28718.html</a><br>
Sent from the RabbitMQ mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rabbitmq-discuss mailing list<br>
<a href="mailto:rabbitmq-discuss@lists.rabbitmq.com">rabbitmq-discuss@lists.rabbitmq.com</a><br>
<a href="https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss" target="_blank">https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br>
</blockquote></div><br></div>