我正在尝试使用apache-camel
配置连接到服务器中的RabbitMQ队列。
使用durable
字段false
和auto-delete
字段true
创建队列时,它可以正常工作。但是当其中任何一个都没有时,它们都不起作用。
applicationContext.xml
文件看起来像这样 -
<bean id="customConnectionFactory" class="com.rabbitmq.client.ConnectionFactory">
<property name="host" value="localhost" />
<property name="port" value="5672" />
<property name="username" value="guest" />
<property name="password" value="guest" />
<property name="virtualHost" value="Test" />
</bean>
<bean id="testBean" class="test.TestBean" />
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<route>
<from
uri="rabbitmq://localhost:5672/ex1?connectionFactory=#customConnectionFactory&queue=Q1&autoDelete=true&durable=true" />
<to uri="bean:testBean?method=hello" /> <!-- This method consumes and prints the message -->
</route>
</camelContext>
在这里,我需要为队列autoDelete
而不是交换durable
指定属性Q1
和ex1
。 (我已经在URI中指定了交换)
错误是 -
Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'auto_delete' for queue 'Q1' in vhost 'Test': received 'true' but current is 'false', class-id=50, method-id=10)
此处 reply-code = 406 表示队列/交换的参数与实际配置不匹配。这是因为这里有队列属性。
由于我无法访问远程队列,因此无法更改队列的属性。 (我在这里说的例子是localhost)
注意:我要求仅使用spring bean执行此操作。