Browse Source

:construction: 更新local下内容

Twelve615 1 year ago
parent
commit
5242dc8214

+ 16 - 13
airport/jeecg-boot-module-system/src/main/java/org/jeecg/modules/api/Test3BusEvent.java

@@ -1,6 +1,7 @@
 package org.jeecg.modules.api;
 
 import cn.hutool.core.util.ObjectUtil;
+import com.google.common.base.Strings;
 import com.rabbitmq.client.Channel;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
@@ -10,6 +11,8 @@ import org.jeecg.boot.starter.rabbitmq.event.JeecgBusEventHandler;
 import org.jeecg.boot.starter.rabbitmq.listenter.MqListener;
 import org.jeecg.common.annotation.RabbitComponent;
 import org.jeecg.common.base.BaseMap;
+import org.jeecg.modules.api.imf.msg.ImfMsg;
+import org.jeecg.modules.api.imf.msg.ImfMsgUtil;
 import org.jeecg.modules.utils.ConversionUtil;
 import org.springframework.amqp.rabbit.annotation.RabbitListener;
 import org.springframework.amqp.support.AmqpHeaders;
@@ -24,6 +27,7 @@ import javax.xml.xpath.XPath;
 import javax.xml.xpath.XPathConstants;
 import javax.xml.xpath.XPathFactory;
 import java.io.StringReader;
+import java.nio.charset.StandardCharsets;
 
 /**
  * @author 王葆权
@@ -32,7 +36,7 @@ import java.io.StringReader;
  * @Description:
  * @date 2023/7/15 15:04
  */
-@Profile("dev")
+@Profile("local")
 @Slf4j
 @RabbitComponent(value = "Test3BusEventListener")
 public class Test3BusEvent extends BaseRabbiMqHandler<Object> {
@@ -44,21 +48,20 @@ public class Test3BusEvent extends BaseRabbiMqHandler<Object> {
     @RabbitListener(queues = "Test3HandlerEvent")
     public void onMessage(BaseMap baseMap, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long deliveryTag) {
         super.onMessage( baseMap, deliveryTag, channel, new MqListener<BaseMap>() {
-            @SneakyThrows
+            //@SneakyThrows
             @Override
             public void handler(BaseMap map, Channel channel) {
                 String xml = map.get( "xml" ).toString();
-                // 将XML字符串转换为字符流
-                StringReader sr = new StringReader( xml );
-                XPathFactory xPathfactory = XPathFactory.newInstance();
-                XPath xpath = xPathfactory.newXPath();
-                DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-                Document doc = factory.newDocumentBuilder().parse( new InputSource( sr ) );
-                String STYP = (String) xpath.evaluate( "/MSG/META/STYP", doc, XPathConstants.STRING );
-
-                log.info( "接收到消息,消息类型STYP={},消息数据:",STYP);
-                log.info("json={}", ConversionUtil.xmlToJson(xml));
-                log.info("XML={}",xml);
+                if (!Strings.isNullOrEmpty(xml)) {
+                    ImfMsg imfMsgObject = ImfMsgUtil.getImfMsgObject(xml);
+                    if (imfMsgObject != null) {
+                        log.info(">>>>>>>>>>>>>>>>>>>>开始处理消息<<<<<<<<<<<<<<<<<<<<");
+                        log.info("获取到消息。消息类型:{},消息内容:{}", imfMsgObject.getTypeName(), xml);
+                        // 处理消息
+                        imfMsgObject.process();
+                        log.info(">>>>>>>>>>>>>>>>>>>>结束处理消息<<<<<<<<<<<<<<<<<<<<");
+                    }
+                }
             }
         } );
     }

+ 1 - 1
airport/jeecg-boot-module-system/src/main/resources/application-dev.yml

@@ -22,7 +22,7 @@ management:
 
 airport:
   mq:
-    msgHandlerEvent: true
+    msgHandlerEvent: false
 
 spring:
 #  thymeleaf:

+ 1 - 1
airport/jeecg-boot-module-system/src/main/resources/application-local.yml

@@ -22,7 +22,7 @@ management:
 
 airport:
   mq:
-    msgHandlerEvent: true
+    msgHandlerEvent: false
 
 spring:
 #  thymeleaf: