数据处理模块新增
parent
702817e275
commit
7f00c32dc7
|
@ -105,7 +105,16 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.iotdb</groupId>
|
||||||
|
<artifactId>iotdb-session</artifactId>
|
||||||
|
<version>1.3.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.iotdb</groupId>
|
||||||
|
<artifactId>node-commons</artifactId>
|
||||||
|
<version>1.3.2</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.muyu.data.util;
|
||||||
|
|
||||||
|
import org.apache.iotdb.isession.util.Version;
|
||||||
|
import org.apache.iotdb.rpc.IoTDBConnectionException;
|
||||||
|
import org.apache.iotdb.session.Session;
|
||||||
|
|
||||||
|
public class Iotdb {
|
||||||
|
public static void main(String[] args) throws IoTDBConnectionException {
|
||||||
|
|
||||||
|
System.out.println("测试数据库开始~~~~~");
|
||||||
|
|
||||||
|
// 初始化与连接
|
||||||
|
Session session = new Session.Builder()
|
||||||
|
.host("47.101.53.251")
|
||||||
|
.port(6667)
|
||||||
|
.username("root")
|
||||||
|
.password("root")
|
||||||
|
.version(Version.V_1_0)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// 开启session Rpc不压缩
|
||||||
|
session.open(false);
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,43 +1,53 @@
|
||||||
package com.muyu.data.util;
|
package com.muyu.data.util;
|
||||||
|
|
||||||
|
import org.eclipse.paho.client.mqttv3.*;
|
||||||
import org.eclipse.paho.client.mqttv3.MqttClient;
|
|
||||||
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
|
|
||||||
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
|
|
||||||
|
|
||||||
public class Receive {
|
public class Receive {
|
||||||
|
|
||||||
public static MqttClient mqttClient= null;
|
|
||||||
private static MemoryPersistence memoryPersistence=null;
|
|
||||||
private static MqttConnectOptions mqttConnectOptions=null;
|
|
||||||
|
|
||||||
private static String ClientName="";
|
|
||||||
|
|
||||||
private static String IP="";
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
String topic = "vehicle";
|
||||||
|
String broker = "tcp://47.101.53.251:1883";
|
||||||
|
String clientId="lw";
|
||||||
|
|
||||||
}
|
try {
|
||||||
|
MqttClient mqttClient= new MqttClient(broker,clientId);
|
||||||
|
MqttConnectOptions connectOptions=new MqttConnectOptions();
|
||||||
|
connectOptions.setCleanSession(true);
|
||||||
|
System.out.println("Connecting to broker:" + broker);
|
||||||
|
mqttClient.connect(connectOptions);
|
||||||
|
System.out.println("已连接");
|
||||||
|
mqttClient.setCallback(new MqttCallback(){
|
||||||
|
|
||||||
public static void start(String clientId){
|
@Override
|
||||||
//初始化连接设置对象
|
public void connectionLost(Throwable throwable) {
|
||||||
mqttConnectOptions = new MqttConnectOptions();
|
System.out.println("Connect lost!");
|
||||||
//设置是否情
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void messageArrived(String s, MqttMessage mqttMessage) throws Exception {
|
||||||
|
System.out.println("Message arrived. topic:"+topic);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mqttClient.subscribe(topic);
|
||||||
|
System.out.println("Subscribed to topic " + topic);
|
||||||
|
} catch (MqttException e) {
|
||||||
|
System.out.println("reason "+e.getReasonCode());
|
||||||
|
System.out.println("msg " +e.getMessage());
|
||||||
|
System.out.println("loc " +e.getLocalizedMessage());
|
||||||
|
System.out.println("cause "+e.getCause());
|
||||||
|
System.out.println("excep "+e);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
package com.muyu.data.util;
|
|
||||||
|
|
||||||
import org.eclipse.paho.client.mqttv3.*;
|
|
||||||
|
|
||||||
public class ReceiveTwo {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
String topic = "vehicle";
|
|
||||||
String broker = "tcp://47.101.53.251:1883";
|
|
||||||
String clientId="lw";
|
|
||||||
|
|
||||||
try {
|
|
||||||
MqttClient mqttClient= new MqttClient(broker,clientId);
|
|
||||||
MqttConnectOptions connectOptions=new MqttConnectOptions();
|
|
||||||
connectOptions.setCleanSession(true);
|
|
||||||
System.out.println("Connecting to broker:" + broker);
|
|
||||||
mqttClient.connect(connectOptions);
|
|
||||||
System.out.println("已连接");
|
|
||||||
mqttClient.setCallback(new MqttCallback(){
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void connectionLost(Throwable throwable) {
|
|
||||||
System.out.println("Connect lost!");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void messageArrived(String s, MqttMessage mqttMessage) throws Exception {
|
|
||||||
System.out.println("Message arrived. topic:"+topic);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
mqttClient.subscribe(topic);
|
|
||||||
System.out.println("Subscribed to topic " + topic);
|
|
||||||
} catch (MqttException e) {
|
|
||||||
System.out.println("reason "+e.getReasonCode());
|
|
||||||
System.out.println("msg " +e.getMessage());
|
|
||||||
System.out.println("loc " +e.getLocalizedMessage());
|
|
||||||
System.out.println("cause "+e.getCause());
|
|
||||||
System.out.println("excep "+e);
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -18,7 +18,8 @@
|
||||||
<module>cloud-modules-wechat</module>
|
<module>cloud-modules-wechat</module>
|
||||||
<module>cloud-modules-breakdown</module>
|
<module>cloud-modules-breakdown</module>
|
||||||
<module>cloud-modules-warn</module>
|
<module>cloud-modules-warn</module>
|
||||||
<module>cloud-data</module>
|
<module>cloud-data</module>
|
||||||
|
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<artifactId>cloud-modules</artifactId>
|
<artifactId>cloud-modules</artifactId>
|
||||||
|
|
Loading…
Reference in New Issue