CZT
2023-10-11 564295458c720206db9b5194b90481b711f4b010
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
//package com.ld.igds.protocol.iot.mq;
//
//import com.ld.igds.io.constant.ProtocolEnum;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.data.redis.connection.RedisConnectionFactory;
//import org.springframework.data.redis.listener.PatternTopic;
//import org.springframework.data.redis.listener.RedisMessageListenerContainer;
//import org.springframework.data.redis.listener.adapter.MessageListenerAdapter;
//
//import java.util.concurrent.CountDownLatch;
//
///**
// * 消息订阅配置
// */
//@Configuration
//public class IotRedisSubConfig {
//
//    /**
//     * 创建连接工厂
//     *
//     * @param connectionFactory
//     * @return
//     */
//    @Bean
//    public RedisMessageListenerContainer container(RedisConnectionFactory connectionFactory,
//                                                   MessageListenerAdapter adapter1,MessageListenerAdapter adapter2) {
//        RedisMessageListenerContainer container = new RedisMessageListenerContainer();
//        container.setConnectionFactory(connectionFactory);
//
//        //监听对应的channel
//        container.addMessageListener(adapter1, new PatternTopic(ProtocolEnum.TCP_FZZY_IOT_V3.getCode()));
//
//        //监听对应的channel
//        container.addMessageListener(adapter2, new PatternTopic(ProtocolEnum.TCP_ZLDZ_GRAIN_V1.getCode() + "_LOGIN"));
//
//        return container;
//    }
//
//    /**
//     * 绑定消息监听者和接收监听的方法
//     *
//     * @param receiver
//     * @return
//     */
//    @Bean
//    public MessageListenerAdapter adapter1(IotReceiverServer receiver) {
//        return new MessageListenerAdapter(receiver, "onMessage");
//    }
//    /**
//     * 绑定消息监听者和接收监听的方法
//     *
//     * @param receiver
//     * @return
//     */
//    /**
//     * 绑定消息监听者和接收监听的方法
//     *
//     * @param receiver
//     * @return
//     */
//    @Bean
//    public MessageListenerAdapter adapter2(IotReceiverServer receiver) {
//        return new MessageListenerAdapter(receiver, "onLoginMessage");
//    }
//
//    @Bean
//    IotReceiverServer receiver(CountDownLatch latch) {
//        return new IotReceiverServer(latch);
//    }
//
//
//    @Bean
//    public CountDownLatch latch() {
//        return new CountDownLatch(1);//指定了计数的次数 1
//    }
//
//}