如何为 java 中的队列设置 属性 'x-message-ttl'

How to set property 'x-message-ttl' for queue in java

如何为此队列设置 '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)

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

您要么需要禁用队列声明

...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