|
@@ -3,6 +3,7 @@ package com.sky.ioc;
|
|
|
import com.sky.ioc.message.MQTTSubsribe;
|
|
|
import org.eclipse.paho.client.mqttv3.MqttException;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.boot.SpringApplication;
|
|
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
|
import org.springframework.boot.builder.SpringApplicationBuilder;
|
|
@@ -25,13 +26,17 @@ public class SkyIocApplication extends SpringBootServletInitializer {
|
|
|
@Autowired
|
|
|
private MQTTSubsribe mqttSubsribe;
|
|
|
|
|
|
+ @Value("${spring.profiles.active}")
|
|
|
+ private String active;
|
|
|
/**
|
|
|
* 接受订阅的接口和消息,mqtt消费端
|
|
|
*/
|
|
|
@PostConstruct
|
|
|
public void consumeMqttClient() throws MqttException {
|
|
|
+ if(active.equals("publish")){
|
|
|
+ mqttSubsribe.start("notice/device/status/safety/camera,notice/device/status/energy/device");
|
|
|
+ }
|
|
|
|
|
|
- // mqttSubsribe.start("notice/device/status/safety/camera,notice/device/status/energy/device");
|
|
|
}
|
|
|
|
|
|
}
|