[rabbitmq-discuss] Exchange to Exchange Bindings

Matthias Radestock matthias at rabbitmq.com
Mon Sep 10 23:41:18 BST 2012


Yuri,

On 10/09/12 21:53, Yurisleidy Hernández Moya wrote:
> I'm testing the Exchange to Exchange Bindings extension but the queue
> does not receive the messages. any idea why?
> this is my code:
>
>   ConnectionFactory factory = new ConnectionFactory();
>          factory.setHost("localhost");
>          Connection connection = factory.newConnection();
>          Channel channel = connection.createChannel();
>
>          channel.exchangeDeclare("ex1", "fanout");
>          channel.exchangeDeclare("ex2", "fanout");
>          channel.exchangeBind("ex1", "ex2", "");
>
>          channel.queueDeclare("queue", false, false, false, null);
>          channel.queueBind("queue", "ex2", "");
>
>          String message = "msg";
>
>          channel.basicPublish("ex1", "", null, message.getBytes());
>          System.out.println(" [x] Sent '" + message + "'");
>
>          channel.close();
>          connection.close();

That binding is the wrong way round. Take a careful look at the 
definition of the parameters at 
http://www.rabbitmq.com/javadoc/com/rabbitmq/client/Channel.html#exchangeBind%28java.lang.String,%20java.lang.String,%20java.lang.String%29


Regards,

matthias.



More information about the rabbitmq-discuss mailing list