1
zhang
4 天以前 e7e980a6276f2986564dfc0afaaf592c592b913b
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package com.zy.acs.hex.config;
 
 
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
 
 
/**
 * RabbitMQ核心配置类,定义交换机、队列和绑定关系
 *
 * @author ken
 */
@Configuration
public class RabbitMQConfig {
 
 
    // ========================== 主题模式 ==========================
    /**
     * 主题交换机名称
     */
    public static final String TOPIC_EXCHANGE = "rcs_topic_exchange";
    /**
     * 主题队列1(上行)
     */
    public static final String TOPIC_QUEUE_UP = "TOPIC_QUEUE_UP";
    /**
     * 主题队列2(下行)
     */
    public static final String TOPIC_QUEUE_DOWN = "TOPIC_QUEUE_DOWN";
 
    // 属性  服务  事件
    //Properties, services, and events
    /**
     * 上行路由键前缀,第一个代表设备编号,第二个代表类型
     */
    public static final String ROUTING_KEY_UP = "rcs.up.*.*";
    /**
     * 下行路由键前缀,第一个代表设备编号,第二个代表类型
     */
    public static final String ROUTING_KEY_DOWN = "rcs.down.*.*";
 
 
    /**
     * 创建主题交换机
     *
     * @return 交换机实例
     */
//    @Bean
//    public TopicExchange topicExchange() {
//        return new TopicExchange(TOPIC_EXCHANGE, true, false);
//    }
 
//    /**
//     * 创建上行主题队列
//     *
//     * @return 队列实例
//     */
//    @Bean
//    public Queue topicQueueUp() {
//        return QueueBuilder.durable(TOPIC_QUEUE_UP)
//                .autoDelete()
//                .exclusive()
//                .build();
//    }
//
//    /**
//     * 创建下行主题队列
//     *
//     * @return 队列实例
//     */
//    @Bean
//    public Queue topicQueueDown() {
//        return QueueBuilder.durable(TOPIC_QUEUE_DOWN)
//                .exclusive()
//                .build();
//    }
//
//
//
//    /**
//     * 绑定上行队列到主题交换机
//     *
//     * @return 绑定关系
//     */
//    @Bean
//    public Binding topicBindingOrder() {
//        return BindingBuilder.bind(topicQueueUp())
//                .to(topicExchange())
//                .with(ROUTING_KEY_UP);
//    }
//
//    /**
//     * 绑定下行队列到主题交换机
//     *
//     * @return 绑定关系
//     */
//    @Bean
//    public Binding topicBindingUser() {
//        return BindingBuilder.bind(topicQueueDown())
//                .to(topicExchange())
//                .with(ROUTING_KEY_DOWN);
//    }
 
 
}