赞
踩
spring.rabbitmq.listener.simple.default-requeue-rejected=false
spring.rabbitmq.listener.simple.retry.enabled=true
@Bean TopicExchange topicExchange() { return new TopicExchange(RabbitMqConfig.EXCHANGE, true, false); } @Bean Queue bizQueue() { Map<String, Object> haArgs = new HashMap<>(); haArgs.put("x-dead-letter-exchange", RabbitMqConfig.EXCHANGE); haArgs.put("x-dead-letter-routing-key", RabbitMqConfig.DEAD_ROUTING_KEY); return new Queue(RabbitMqConfig.ORDER_QUEUE, true, false, false, haArgs); } @Bean Queue deadLetterQueue() { return QueueBuilder.durable(RabbitMqConfig.DEAD_QUEUE).build(); } @Bean Binding deadBinding() { return BindingBuilder.bind(deadLetterQueue()).to(topicExchange()).with(RabbitMqConfig.DEAD_ROUTING_KEY); } @RabbitListener(queues = RabbitMqConfig.DEAD_QUEUE) public void deadletterMessage(Message msg) { logger.info("{}---------------------------dead msg---------------:{}", msg.getClass().getName(), msg); }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。