rabbitMQ延迟队列的实现

 原理图:

rabbitMQ延迟队列的实现_第1张图片

 

rabbitMQ延迟队列的实现_第2张图片

 

 

理论:

1关于springboot中配置,没有找到在application.yml中配置具体的exchange,queue,binding即关系的建立,都是通过java配置实现的,在yml中只有配置基本的链接

2关于如何配置3种关系

 1 写java类定义bean:Queue,Exchange,Binding

 2 只在java类种定义bean:Queue,Exchange,Binding放在消费者监听方法上

   queue和消费方关联,生产者只需指定exchange,routing

 

//生产者发送消息:
rabbitTemplate.convertAndSend(String exchange, String routingKey, Object object)
//消费者监听消息:
@RabbitListener(
            bindings = @QueueBinding(
                    value = @Queue(
                            value = "myQueue6",
                            arguments = {
                                    @Argument(name = "x-dead-letter-exchange", value = "myExchange1_dlx"),
                                    @Argument(name = "x-dead-letter-routing-key", value = "routingKey4_dlx")}),
                    exchange = @Exchange(value = "myExchange1"),
                    key = "routingKey4"
            ))
    public void process7(Message message, Channel channel) throws Exception {
}

你可能感兴趣的:(rabbitMQ延迟队列的实现)