我有一个非常简单的场景。我创建一个队列,交换并绑定队列进行交换。
Code :
String queueName = new StringBuilder("LP.DATA.").append("TESTACCOUNT").append(".").append("subLP").toString();
channel.exchangeDeclare(ExchangeConstants.DATA_EXCG, "direct", true);
channel.queueDeclare(queueName, true, false, false, null);
channel.exchangeBind(queueName, ExchangeConstants.DATA_EXCG, queueName);
I get the following error when exchangeBind() is called.
com.rabbitmq.client.ShutdownSignalException: channel error; reason: {#method<channel.close>(reply-code=404, reply-text=NOT_FOUND - no exchange 'LP.DATA.TESTACCOUNT.subLP' in vhost '/', class-id=40, method-id=30), null, ""}
My ExchangeConstants.DATA_EXCG is "DATA_EXCG". Using RabbitMq admin I see that the exchange and queue are all created. From the exception I don't understand why is it looking for exchange with name "LP.DATA.TESTACCOUNT.subLP", this is a queuename. It seems quite trivial, I am sure I am missing something.
I am using java rabbitmq-client version 3.04.
答案 0 :(得分:2)
channel.exchangeBind(java.lang.String destination,
java.lang.String source,
java.lang.String routingKey)
这个函数绑定2交换:目的地和源都应该是交换。
在这里,您应该使用channel.queueBind
。