2021与蓝度共同重构项目,服务端
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
package com.sandu.ximon.admin.localMQTT.controller;
 
import com.sandu.ximon.admin.localMQTT.util.MqttClientUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import static java.lang.Thread.sleep;
 
/**
 * @author van
 * @version 1.0
 * msg:
 * @date 2022/11/11 14:18
 */
@RestController
@RequestMapping("/localMQTT")
@Slf4j
public class localMQTTTestController {
 
 
    @RequestMapping("/test")
    public static String localMQTT() throws InterruptedException {
 
        for (int i = 0; i < 10; i++) {
 
            String result1 = MqttClientUtil.sendMqttMsg("363832544E5008FF3A32FFFF",
                    "FEA501000BFE010003FFFF0045971477B6D8C2CA");
            log.info("返回结果:"+result1);
            sleep(1000);
            String result2 = MqttClientUtil.sendMqttMsg("363832544E5008FF3A32FFFF",
                    "FEA501000BFE010003FFFF640F48B1367ABDE0B9");
            log.info("返回结果:"+result2);
            sleep(1000);
 
        }
 
 
        return "OK";
    }
}