Jay
2024-11-08 02722a3f9eca857ce7fffea352e9f7ee692a1b71
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
36
37
38
39
40
41
42
43
44
45
46
47
48
package com.iailab.module.data.mq.config;
 
import com.iailab.module.data.mq.consumer.ImageMessage;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
 
/**
 * @author Houzhongjian
 * @Description
 * @createTime 2024年11月06日
 */
@Configuration
public class TopicImageRabbitConfig {
    //绑定键
    public final static String routingDahua = ImageMessage.DAHUA_ROUTING_KEY;
    public final static String routingHikvison = ImageMessage.HIKVISION_ROUTING_KEY;
 
    @Bean
    public Queue imageDahuaQueue() {
        return new Queue(TopicImageRabbitConfig.routingDahua);
    }
 
    @Bean
    public Queue imageHikvisionQueue() {
        return new Queue(TopicImageRabbitConfig.routingHikvison);
    }
 
    @Bean
    TopicExchange exchange() {
        return new TopicExchange(ImageMessage.EXCHANGE);
    }
 
    // 注意通配符*和#的用法
    @Bean
    Binding bindingExchangeMessageDH() {
        return BindingBuilder.bind(imageDahuaQueue()).to(exchange()).with(routingDahua);
    }
 
    @Bean
    Binding bindingExchangeMessageHK() {
        return BindingBuilder.bind(imageHikvisionQueue()).to(exchange()).with(routingHikvison);
    }
 
}