背景
使用开源thingsboard,需要熟悉thingsboard源码
介绍
1.通过配置文件入手:
@Value(“${transport.mqtt.bind_port}”)
2.处理设备mqtt连接平台的类
MqttTransportService 里面有@PostConstruct
3.具体处理类
处理数据类:MqttTransportHandler
4.所有topic类
MqttTopics
5.怎么建立连接的,建立连接怎么验证账号密码的,连接:
MqttTransportHandler#processConnect#processAuthTokenConnect
6.默认的处理类
DefaultTransportService#doProcess#399
7.默认的queue
DefaultTbQueueRequestTemplate
8.默认的内存队列
private final ConcurrentHashMap<String, BlockingQueue>
storage = new ConcurrentHashMap<>(); DefaultInMemoryStorage#put(String
topic, TbQueueMsg msg) DefaultInMemoryStorage#get
9.内存队列工厂
InMemoryMonolithQueueFactory#createRuleEngineMsgProducer
InMemoryMonolithQueueFactory#createToRuleEngineMsgConsumerInMemoryMonolithQueueFactory#createRuleEngineNotificationsMsgProducer
InMemoryMonolithQueueFactory#createToRuleEngineNotificationsMsgConsumer
10.tb核心队列生产者提供者,默认
TbCoreQueueProducerProvider#@PostConstruct#init
11.消费内存数据-拉取数据
InMemoryTbQueueConsumer#poll
12.规则引擎消费数据返回结果数据:
DefaultTbRuleEngineConsumerService#init
13.消费业务
DefaultTbRuleEngineConsumerService#consumerLoop