elkers
2025-04-07 2dba8dbb14af4616eec876fd9af744651e8beeda
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
package com.nanjing.water.host.mqtt;
 
import com.nanjing.water.common.config.MqttConfig;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
 
import java.util.Objects;
 
@Component
@Order(40)
public class MQTTStart implements InitializingBean {
    @Autowired
    private MQTTSubsribe mqttSubsribe;
    @Autowired
    private MqttConfig mqttConfig;
 
    @Override
    public void afterPropertiesSet() throws Exception {
        if (Objects.equals(mqttConfig.getEnable(), Boolean.FALSE)) {
            return;
        }
        mqttSubsribe.init();
    }
}