0

我依赖 CloudAMQP 服务,我需要能够支持最大 10 兆字节的消息:

1. Map<String, Object> params = new HashMap<>();
2. params.put("x-ha-policy", "all");
3. params.put("x-max-length-bytes", 10_000_000);
4. channel.queueDeclare(messageQueueName, true, false, false, params);

我的问题是,只要第 3 行没有被注释掉,队列就会抛出异常:

Caused by: com.rabbitmq.client.ShutdownSignalException: 
channel error; reason: {#method<channel.close>(reply-code=406,
reply-text=PRECONDITION_FAILED - 
inequivalent arg 'x-max-length-bytes' for queue 'someQueueName' 
in vhost 'yzscezrk': received none but current is the value '1000000'
of type 'signedint

我在这里做错了什么?

4

1 回答 1

0

PRECONDITION_FAILED 表示您已经声明了一个队列,并且您正在尝试使用不同的参数创建相同的队列。

队列已经有参数 x-max-length-bytes 并且很可能您正在尝试更改它。

您可以删除队列(您将丢失消息)并尝试使用您需要的参数再次创建它

于 2018-11-25T17:17:02.817 回答