如何在 Rabbit 中设置 x-dead-letter-exchange?

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

这是我的豆子:

    @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);
    }

这里是 application.yml 设置:

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

我目前的错误:

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)

我该如何解决?我需要从 listenerQueue 中取出死信并将它们放入 dlxQueue

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

这意味着您在代理上已经有一个 igSmev3-ListenerQueue 队列并且它没有 'x-dead-letter-exchange' 参数。可能你以前用那个状态创建过它。

在启动已提供 DLX 的应用程序之前,请考虑删除此队列。