【问题标题】:How to set property 'x-message-ttl' for queue in java如何在java中为队列设置属性'x-message-ttl'
【发布时间】:2020-04-09 14:37:06
【问题描述】:

如何为这个队列设置“x-message-ttl”属性?

rabbit:
            bindings:
              TEST_RESPONSE:
                consumer:
                  bindingRoutingKey: "'${routing}'"
                  prefetch: ${prefetch}
                  acknowledge-mode: MANUAL
          bindings:
            TEST_RESPONSE:
              destination: TEST_RESPONSE
              content-type: application/json
              group: test

因为有这个错误

Channel shutdown: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'x-message-ttl' for queue 'TEST_RESPONSE.test' in vhost '/': received none but current is the value '60000' of type 'long', class-id=50, method-id=10)

【问题讨论】:

  • 看来您需要添加一个spring-cloud-stream 标签。看起来这不是 RabbitMQ 甚至 Spring AMQP 问题。由于您有一个队列已经声明了来自 Rabbit Binder 的被动声明,因此应该以某种方式禁用...
  • 这不是所有application.yml,因为它太大了,我只想知道如何用这个属性'x-message-ttl'声明quene?
  • 看我的回答。

标签: properties rabbitmq spring-cloud-stream spring-rabbit


【解决方案1】:

队列定义是不可变的;您不能更改队列参数。

您需要禁用队列声明

...rabbit.bindings.foo.consumer.bindQueue: false

或添加

...rabbit.bindings.foo.consumer.ttl: 60000

匹配现有定义。

查看消费者属性。

https://cloud.spring.io/spring-cloud-static/spring-cloud-stream-binder-rabbit/3.0.3.RELEASE/reference/html/spring-cloud-stream-binder-rabbit.html#_rabbitmq_consumer_properties

【讨论】:

  • 非常感谢,正是我要找的东西
猜你喜欢
  • 2017-01-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-02-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-05-24
相关资源
最近更新 更多