我正在尝试将Apache QPID Broker (版本7.1.6)作为内存代理中的嵌入式运行,并在代理上声明一个队列,同时将队列声明选项x-qpid-dlq-enabled设置为"true“。
public void createQueues() throws Exception {
//connect to embedded broker running on local host
ConnectionFactory factory = createConnectionFactory();
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();
Map<String, Object> args = new HashMap<>();
args.put("x-qpid-dlq-enabled",true);
channel.queueDeclare("Test Queue", true, false, false, args);根据这里找到的参数"x-qpid-dlq-enabled“的条目:https://qpid.apache.org/releases/qpid-broker-j-7.1.0/book/Java-Broker-Appendix-Queue-Declare-Arguments.html
并根据此处第9.4.3节中描述的行为:https://qpid.apache.org/releases/qpid-java-6.1.0/java-broker/book/Java-Broker-Runtime-Handling-Undeliverable-Messages.html
预期的行为是,如果使用该选项,则会自动创建死信交换和死信队列。从上面的第二个链接开始:
“DLQ功能导致生成死信交换和死信队列。它们被命名为约定QueueName_DLE和QueueName_DLQ。
可以在创建新队列时启用dlq,也可以使用队列声明属性x-qpid-dlq- enabled启用dlq。“
然而,当我试图使用这个declare参数声明一个队列时,我收到了下面的错误。
Exception in thread "main" java.io.IOException
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:129)
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:125)
at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:147)
at com.rabbitmq.client.impl.ChannelN.queueDeclare(ChannelN.java:968)
at com.rabbitmq.client.impl.recovery.AutorecoveringChannel.queueDeclare(AutorecoveringChannel.java:333)
at BrokerConnector.createQueues(BrokerConnector.java:43)
at Main.main(Main.java:11)
Caused by: com.rabbitmq.client.ShutdownSignalException: connection error; protocol method: #method<connection.close>(reply-code=404, reply-text=Unknown alternate exchange: 'Test Queue_DLQ', class-id=50, method-id=10)
at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:66)我正在使用RabbitMQ client创建到QPID Broker的AMQPConnection,客户端和broker都在使用AMQ protocol v 0_8。为什么QPID文档中指定的相应交换不是自动创建的,为什么交换名称的后缀是"_DLQ",而不是文档中指定的"_DLE“。我知道Qpid for Java version6中记录了这种行为,并且我正在运行7.1.6版,但是后来的文档中没有任何发行说明指出该行为应该有所不同,并且7.1.6版的文档仍然表明支持"x-qpid-dlq-enable"参数。
有什么建议或想法吗?
发布于 2019-12-23 18:35:02
在Qpid Broker J的7.0版本中,配置死信队列的方式发生了变化。不幸的是,看起来v6机制留下了一些代码(和文档),这导致了您看到的错误。
从版本7开始,您可以直接在队列上设置DLQ (或者更准确地说,是备用绑定),而不需要备用交换。
如果你想让这一切自动发生,qpid-users@apache.org邮件列表上的以下邮件交换可能会被证明是有用的:http://qpid.2158936.n2.nabble.com/Qpid-Broker-J-configure-alternate-binding-in-Node-auto-creation-policy-tp7684426.html
为我之前的(完全错误的)猜测道歉--我承认代码的一部分不是我经常看到的。
https://stackoverflow.com/questions/59397665
复制相似问题