rabbitmq死信队列的绑定

    @Bean
    public Queue queue() {
        Map<String, Object> arguments = new HashMap<>();
        //设置整个队列的过期时间 durable 表示是否持久化队列,即服务器重启后队列依然存在
        arguments.put("x-message-ttl", 20000);
        //绑定死信交换机
        arguments.put("x-dead-letter-exchange", "exchange.dlx");
        //指定RoutingKey 要与死信队列与死信交换机之间的相同
        arguments.put("x-dead-letter-routing-key", "error");
        return new Queue("queue.direct.i", true, false, false, arguments);
    }
    @Bean
    public DirectExchange dlxExchange() {
        return ExchangeBuilder.directExchange("exchange.dlx").build();
    }

    @Bean
    public Queue dlxQueue() {
        return QueueBuilder.durable("queue.dlx").build();
    }

    @Bean
    public Binding bindingDlx(DirectExchange dlxExchange, Queue dlxQueue) {
        return BindingBuilder.bind(dlxQueue).to(dlxExchange).with("error");
    }

你可能感兴趣的:(rabbitmq,分布式)