| | |
| | | package com.iailab.module.data.mq.consumer; |
| | | |
| | | import org.springframework.amqp.core.ExchangeTypes; |
| | | import org.springframework.amqp.rabbit.annotation.*; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | |
| | | * @createTime 2024年11月05日 |
| | | */ |
| | | @Component |
| | | @RabbitListener( |
| | | bindings = @QueueBinding( |
| | | value = @Queue( |
| | | // 在 Queue 的名字上,使用 UUID 生成其后缀。这样,启动的 Consumer 的 Queue 不同,以达到广播消费的目的 |
| | | name = ImageMessage.DAHUA_ROUTING_KEY, |
| | | // Consumer 关闭时,该队列就可以被自动删除了 |
| | | autoDelete = "true" |
| | | ), |
| | | exchange = @Exchange( |
| | | name = ImageMessage.EXCHANGE, |
| | | type = ExchangeTypes.TOPIC, |
| | | declare = "false", |
| | | autoDelete = "true" |
| | | ) |
| | | ) |
| | | ) |
| | | @RabbitListener( |
| | | bindings = @QueueBinding( |
| | | value = @Queue( |
| | | // 在 Queue 的名字上,使用 UUID 生成其后缀。这样,启动的 Consumer 的 Queue 不同,以达到广播消费的目的 |
| | | name = ImageMessage.HIKVISION_ROUTING_KEY, |
| | | // Consumer 关闭时,该队列就可以被自动删除了 |
| | | autoDelete = "true" |
| | | ), |
| | | exchange = @Exchange( |
| | | name = ImageMessage.EXCHANGE, |
| | | type = ExchangeTypes.TOPIC, |
| | | declare = "false", |
| | | autoDelete = "true" |
| | | ) |
| | | ) |
| | | ) |
| | | @RabbitListener(queues = ImageMessage.DAHUA_ROUTING_KEY) |
| | | @RabbitListener(queues = ImageMessage.HIKVISION_ROUTING_KEY) |
| | | public class ImageConsumer { |
| | | |
| | | // @RabbitHandler |
| | | public void process(ImageMessage imageMessage) throws InterruptedException { |
| | | System.out.println("1111111111111111111111111"); |
| | | System.out.println("测试消费摄像头截图RabbitMQ消息----------------------"); |
| | | Thread.sleep(5000); |
| | | System.out.println(imageMessage.toString()); |
| | | System.out.println(new Date()); |