当前位置:   article > 正文

spring rabbitmq 死信队列配置_spring.rabbitmq.listener.simple.default-requeue-re

spring.rabbitmq.listener.simple.default-requeue-rejected=false yamal
spring.rabbitmq.listener.simple.default-requeue-rejected=false
spring.rabbitmq.listener.simple.retry.enabled=true
  • 1
  • 2


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


  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/139132
推荐阅读
相关标签
  

闽ICP备14008679号