Bladeren bron

修改rabbitMq.server.ip为内网端口,增加Basic

ZhangNing 1 maand geleden
bovenliggende
commit
50fb54a6eb

+ 0 - 50
src/main/java/com/xyhy/jiaranmqttcluster/common/message/MessageHandle.java

@@ -1,50 +0,0 @@
-package com.xyhy.jiaranmqttcluster.common.message;
-
-import com.alibaba.fastjson.JSONObject;
-
-public class MessageHandle {
-
-    public static void vehicleOnline(String s, JSONObject msg){
-
-    }
-
-    public static void vehicleOffline(String s, JSONObject msg){
-
-    }
-
-    public static void fuelState(String s, JSONObject msg){
-
-    }
-
-    public static void vehicleState(String s, JSONObject msg){
-
-    }
-
-    public static void arriveStationRequest(String s, JSONObject msg){
-
-    }
-
-    public static void arrivePoint(String s, JSONObject msg){
-
-    }
-
-    public static void leavePoint(String s, JSONObject msg){
-
-    }
-
-    public static void gotoPoint(String s, JSONObject msg){
-
-    }
-
-    public static void taskBegin(String s, JSONObject msg){
-
-    }
-
-    public static void taskOver(String s, JSONObject msg){
-
-    }
-
-    public static void startCarFailMsg(String s, JSONObject msg){
-
-    }
-}

+ 2 - 30
src/main/java/com/xyhy/jiaranmqttcluster/common/mqtt/MqttGetMessage.java

@@ -1,9 +1,6 @@
 package com.xyhy.jiaranmqttcluster.common.mqtt;
 
-import com.alibaba.fastjson.JSONObject;
-
 import com.xyhy.jiaranmqttcluster.common.Common;
-import com.xyhy.jiaranmqttcluster.common.message.MessageHandle;
 import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
 import org.eclipse.paho.client.mqttv3.MqttCallback;
 import org.eclipse.paho.client.mqttv3.MqttMessage;
@@ -15,37 +12,12 @@ public class MqttGetMessage extends Common implements MqttCallback {
 
     @Override
     public void connectionLost(Throwable throwable) {
-        log.error("MQTT连接已经断开!");
+
     }
 
     @Override
     public void messageArrived(String s, MqttMessage mqttMessage) throws Exception {
-        JSONObject msg = JSONObject.parseObject(new String(mqttMessage.getPayload()));
-        String msgType = msg.getString("msgType");
-        switch (msgType){
-            case "1":
-                MessageHandle.vehicleOnline(s, msg);
-            case "2":
-                MessageHandle.vehicleOffline(s, msg);
-            case "3":
-                MessageHandle.fuelState(s, msg);
-            case "4":
-                MessageHandle.vehicleState(s, msg);
-            case "19":
-                MessageHandle.arriveStationRequest(s, msg);
-            case "102":
-                MessageHandle.arrivePoint(s, msg);
-            case "103":
-                MessageHandle.leavePoint(s, msg);
-            case "101":
-                MessageHandle.gotoPoint(s, msg);
-            case "800":
-                MessageHandle.taskBegin(s, msg);
-            case "801":
-                MessageHandle.taskOver(s, msg);
-            case "501":
-                MessageHandle.startCarFailMsg(s, msg);
-        }
+
     }
 
     @Override

+ 7 - 1
src/main/java/com/xyhy/jiaranmqttcluster/common/mqtt/MqttServer.java

@@ -57,11 +57,17 @@ public class MqttServer extends Common {
         try {
             client=new MqttClient(host,clientID,new MemoryPersistence());
             MqttConnectOptions options=new MqttConnectOptions();
-            options.setCleanSession(true);
+            options.setCleanSession(false);
             options.setUserName(username);
             options.setPassword(password.toCharArray());
             options.setConnectionTimeout(timeout);
             options.setKeepAliveInterval(keeplive);
+            options.setAutomaticReconnect(true);
+//            options.setCleanSession(true);
+//            options.setUserName(username);
+//            options.setPassword(password.toCharArray());
+//            options.setConnectionTimeout(timeout);
+//            options.setKeepAliveInterval(keeplive);
             _client = client;
             try {
                 client.setCallback(new MqttGetMessage());

+ 3 - 3
src/main/java/com/xyhy/jiaranmqttcluster/common/rabbitmq/listening/Listen_thirdPartyPush_jiaran.java

@@ -6,6 +6,8 @@ import com.xyhy.jiaranmqttcluster.common.Basic;
 import com.xyhy.jiaranmqttcluster.common.Common;
 import com.xyhy.jiaranmqttcluster.common.message.back.MessageBackThreadGroupCommon;
 import com.xyhy.jiaranmqttcluster.common.message.back.Message_back_thirdPartyPush_jaran;
+import com.xyhy.jiaranmqttcluster.common.mqtt.MqttGetMessage;
+import com.xyhy.jiaranmqttcluster.common.mqtt.MqttServer;
 import com.xyhy.jiaranmqttcluster.common.rabbitmq.RabbitUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -37,9 +39,7 @@ public class Listen_thirdPartyPush_jiaran {
 
                     String message = new String(body, "UTF-8");
                     log.info(message);
-//                    Message_back_thirdPartyPush_jaran work = new Message_back_thirdPartyPush_jaran();
-//                    work.setOb(JSON.parseObject(message));
-//                    MessageBackThreadGroupCommon.getThreadGroupCom().getWorkThreadPool().execute(work);
+                    MqttServer.getInstance().pushlish(Common.getConfigByName("MQTT.server.Subscribe"), message);
                 }
             };
             // channel绑定队列、消费者,autoAck为true表示一旦收到消息则自动回复确认消息

+ 5 - 25
src/main/resources/application.properties

@@ -13,39 +13,19 @@ MQTT.server.keepAlive=60
 ##MQTT.server.Subscribe=$queue\\101,$queue\\103,$queue\\105,$queue\\201,$queue\\302,$queue\\303,$queue\\305,$queue\\306,$queue\\309,$queue\\401,$queue\\501
 ##MQTT.server.Subscribe=xs/v1/business/boot/task/notify/important/msg/queue/34,xs/v1/business/boot/boot/task/notify/msg/queue/34
 #MQTT.server.Subscribe=xs/business/boot/task/notify/important/msg/queue/6
-MQTT.server.Subscribe=xs/v1/business/boot/boot/task/notify/msg/queue/34
+MQTT.server.Subscribe=XYHY_FUNCTION/101
 
 #######WEB SERVER###########
 server.port=20001
 
 
-#######REDIS SERVER#########
-redis.server.ip=39.98.37.180
-redis.server.port=6397
-redis.server.db=11
-redis.server.pw=boxun91#Rs
-reids.server.MaxTotal=50
-reids.server.MaxIdle=20
-reids.server.MinIdle=10
-reids.server.MaxWaitMillis=3000
-reids.server.TestOnBorrow=true
-reids.server.Timeout=3000
-
-
-
-#######Charging interface service###########
-charging.interface.api.port=9999
-charging.interface.api.realtime=/realtime/restapi/realtime/
-charging.interface.api.pileLog=/web/restapi/pileLog/
-charging.interface.api.url.produce=https://cdglyy.pjnes.com/
-charging.interface.api.url.test=https://jqcs.pjnes.com/
-charging.interface.api.url.status=debug
-
 
 #logging.level.root=error
 
 #######rabbitMQ###########
-rabbitMq.server.ip=172.26.76.31
+#rabbitMq.server.ip=172.26.76.31
+rabbitMq.server.ip=172.26.76.38
+
 rabbitMq.server.port=5673
 rabbitMq.server.vHost=/
 rabbitMq.server.userName=rabbit
@@ -59,4 +39,4 @@ rabbitMq.server.TOIMPLSERVEREXCHANGE=TOIMPLSERVEREXCHANGE
 rabbitMq.server.TOREALTIMEDATASERVEREXCHANGE=TOREALTIMEDATASERVEREXCHANGE
 
 #######log projectName###########
-project.name=jiaranMQTTCluster
+project.name=XYHY_jiaranMQTTCluster