How to set x-dead-letter-exchange in Rabbit?

假装没事ソ 提交于 2020-07-10 10:25:21

问题


Here are my beans:

    @Bean
    public Queue igSmev3ListenerQueue() {
        Map<String, Object> args = new HashMap<>();
        args.put("x-dead-letter-exchange", rabbitIgSmev3DlxProperties.getExchangeName());
        args.put("x-dead-letter-routing-key", rabbitIgSmev3DlxProperties.getRoutingKey());
        return new Queue(rabbitIgSmev3ListenerProperties.getQueueName(), true, false, false, args);
    }

    @Bean
    public Queue igSmev3DlxQueue() {
        return new Queue(rabbitIgSmev3DlxProperties.getQueueName(), true, false, false);
    }

Here are application.yml settings:

listener:
  vhost: /
  exchangeName: igSmev3Listener
  queueName: igSmev3-ListenerQueue
  routingKey: igSmev3-Listener
dlx:
  vhost: /
  exchangeName: igSmev3Dlx
  queueName: igSmev3-DlxQueue
  routingKey: igSmev3-Dlx

My current error:

Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'x-dead-letter-exchange' for queue 'igSmev3-ListenerQueue' in vhost '/': received none but current is the value 'igSmev3Dlx' of type 'longstr', class-id=50, method-id=10)

How can I solve it? I need to take dead letters from listenerQueue and put them to dlxQueue


回答1:


inequivalent arg 'x-dead-letter-exchange' for queue 'igSmev3-ListenerQueue' in vhost '/': received none but current is the value 'igSmev3Dlx' of type 'longstr'

That means that you have a igSmev3-ListenerQueue queue on the broker already and it is without an 'x-dead-letter-exchange' argument. Probably you have created it before with that state.

Consider to remove this queue before starting your application with already DLX provided.



来源:https://stackoverflow.com/questions/62792713/how-to-set-x-dead-letter-exchange-in-rabbit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!