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

Brett Cameron brett.r.cameron at gmail.com
Mon Aug 12 05:58:16 BST 2013


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.

Brett



On Mon, Aug 12, 2013 at 4:44 PM, k.madnani84 <k.madnani84 at gmail.com> wrote:

> 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.
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20130812/dba16e73/attachment.htm>


More information about the rabbitmq-discuss mailing list