0

我正在玩兔子,并尝试将消息发布到现有队列。不幸的是,Bunny 内部的文档是针对消费者创建的,而不是针对生产者的。因此,例如,当我尝试绑定到某个交换时,它会引发错误

PRECONDITION_FAILED - cannot redeclare exchange 'test' in vhost '/' with different type, durable, internal or autodelete value

代码:

conn = Bunny.new()
conn.start
ch = conn.create_channel
x = ch.direct("test")

你知道它为什么要重新声明吗?

也许我需要先绑定到队列?

谢谢你的帮助。

4

2 回答 2

2

错误消息告诉你你试图重新声明一个交换,但你改变了它的一些参数。

如果您只是在测试,请删除交换并重新运行您的脚本。

我们这里也有一套教程:http ://www.rabbitmq.com/getstarted.html

于 2014-09-23T16:58:31.747 回答
0

I've ran into this problem too. If you've already setup the exchange in RabbitMQ. Make sure that you bind the exchange to your queue. You can either do that in the RabbitMQ admin or via the command line using the rabbitmqctl command.

Next, verify that the exchange you are using is a "direct" exchange. By default, when creating an exchange in the RabbitMQ admin it will generate a "topic" exchange. After you verify they are the same, then you should not get the error message.

于 2016-01-25T17:19:33.470 回答