【问题标题】:SpringAMQP Queue creation with args使用 args 创建 SpringAMQP 队列
【发布时间】:2016-07-07 00:58:12
【问题描述】:

我创建了一个带有消息过期参数的队列,但在启动服务器时出现以下错误。

[SimpleAsyncTaskExecutor-1] o.s.a.r.c.RabbitAdmin [RabbitAdmin.java:375] Auto-declaring a non-durable Queue (TEST_QUEUE). It will be redeclared if the broker stops and is restarted while the connection factory is alive, but all messages will be lost.
pool-1-thread-1] o.s.a.r.c.CachingConnectionFactory [CachingConnectionFactory.java:249] Channel shutdown: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'durable' for queue 'EXP_MSG' in vhost '/': received 'false' but current is 'true', class-id=50, method-id=10)
ERROR [SimpleAsyncTaskExecutor-1] o.s.a.r.l.SimpleMessageListenerContainer [SimpleMessageListenerContainer.java:914] Failed to check/redeclare auto-delete queue(s).
org.springframework.amqp.AmqpIOException: java.io.IOException
    at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:63) ~[spring-rabbit-1.4.0.RELEASE.jar:na]
    at org.springframework.amqp.rabbit.connection.RabbitAccessor.convertRabbitAccessException(RabbitAccessor.java:110) ~[spring-rabbit-1.4.0.RELEASE.jar:na]

我使用 Spring boot 1.2.8 和 Spring 4.2.5 版本。

   @Bean
    Queue expiredMessageQueue() {
        Map args = new HashMap();
        args.put("x-message-ttl", 60000);
        return new Queue(expiredMessageQueue, false, false, false,args);
    }

【问题讨论】:

    标签: rabbitmq spring-amqp


    【解决方案1】:

    vhost '/' 中队列 'EXP_MSG' 的不等价参数 'durable':收到 'false' 但当前为 'true'

    这意味着在 RabbitMQ Broker 上已经存在这样的队列,但具有不同的属性。

    如果您想更改它并通过应用程序重新创建,您应该先从代理中删除它,然后再启动应用程序。或者将所有选项与现有选项对齐。

    这被称为passiveDeclaration。监听器确实需要一个真正的队列来订阅,只有为什么要检查它是否以所需状态存在,尝试在监听器启动时声明它。

    【讨论】:

      猜你喜欢
      • 2013-02-13
      • 2018-02-13
      • 2014-02-11
      • 2013-09-14
      • 2011-10-10
      • 2011-12-15
      • 2017-09-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多