瀏覽代碼

:white_check_mark:更换mq

Twelve615 1 年之前
父節點
當前提交
57e23cbcdc

+ 5 - 20
airport/jeecg-boot-module-system/src/main/java/org/jeecg/modules/api/Test3BusEvent.java → airport/jeecg-boot-module-system/src/main/java/org/jeecg/modules/api/AirportBusEvent.java

@@ -1,33 +1,18 @@
 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;
 import org.jeecg.boot.starter.rabbitmq.core.BaseRabbiMqHandler;
-import org.jeecg.boot.starter.rabbitmq.event.EventObj;
-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;
 import org.springframework.context.annotation.Profile;
 import org.springframework.messaging.handler.annotation.Header;
-import org.springframework.stereotype.Component;
-import org.w3c.dom.Document;
-import org.xml.sax.InputSource;
-
-import javax.xml.parsers.DocumentBuilderFactory;
-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 王葆权
@@ -38,14 +23,14 @@ import java.nio.charset.StandardCharsets;
  */
 @Profile("local")
 @Slf4j
-@RabbitComponent(value = "Test3BusEventListener")
-public class Test3BusEvent extends BaseRabbiMqHandler<Object> {
+@RabbitComponent(value = "AirportBusEventListener")
+public class AirportBusEvent extends BaseRabbiMqHandler<Object> {
 
-    public Test3BusEvent() {
-        System.out.println("¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥Test3BusEvent消息总栈事件创建了¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥");
+    public AirportBusEvent() {
+        System.out.println("¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥AirportBusEvent消息总栈事件创建了¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥");
     }
 
-    @RabbitListener(queues = "Test3HandlerEvent")
+    @RabbitListener(queues = "acdmMsgLocalHandlerEvent")
     public void onMessage(BaseMap baseMap, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long deliveryTag) {
         super.onMessage( baseMap, deliveryTag, channel, new MqListener<BaseMap>() {
             //@SneakyThrows

+ 2 - 2
airport/jeecg-boot-module-system/src/main/java/org/jeecg/modules/api/imf/ImfMqListener.java

@@ -47,7 +47,7 @@ public class ImfMqListener extends BaseRabbiMqHandler<Object> {
     }
 
 
-    @RabbitListener(queues = "test3")
+    @RabbitListener(queues = "acdmMsg")
     public void onMessage3(Message message, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long deliveryTag) {
         super.onMessage(message, deliveryTag, channel, new MqListener<Message>() {
             @Override
@@ -59,7 +59,7 @@ public class ImfMqListener extends BaseRabbiMqHandler<Object> {
                             //转发消息到消息总栈测试, 避免本地测试消费消息
                             BaseMap params = new BaseMap();
                             params.put("xml", xml);
-                            rabbitMqClient.sendMessage("Test3HandlerEvent", params);
+                            rabbitMqClient.sendMessage("acdmMsgLocalHandlerEvent", params);
                         }
                         log.info("消息内容:{}", xml);
                         ImfMsg imfMsgObject = ImfMsgUtil.getImfMsgObject(xml);

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

@@ -36,11 +36,11 @@ spring:
 #    encoding: UTF-8
   # 配置RabbitMQ服务器>>>>>>单机配置
   rabbitmq:
-    host: 120.79.86.50
+    host: 111.229.112.155
     port: 5672
-    username: zl
-    password: 123456
-    virtual-host: /
+    username: admin
+    password: AirportAdmin2023+
+    virtual-host: /airport
     listener: #开启消费者确认机制
       simple:
         # 每次从RabbitMQ获取的消息数量

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

@@ -36,11 +36,11 @@ spring:
 #    encoding: UTF-8
   # 配置RabbitMQ服务器>>>>>>单机配置
   rabbitmq:
-    host: 120.79.86.50
+    host: 111.229.112.155
     port: 5672
-    username: zl
-    password: 123456
-    virtual-host: /
+    username: admin
+    password: AirportAdmin2023+
+    virtual-host: /airport
     listener: #开启消费者确认机制
       simple:
         # 每次从RabbitMQ获取的消息数量

+ 5 - 5
airport/jeecg-boot-module-system/src/main/resources/application-prod.yml

@@ -29,7 +29,7 @@ management:
 
 airport:
   mq:
-    msgHandlerEvent: true
+    msgHandlerEvent: false
   system:
     host: https://wnzjszs.wzair.cn/airport
     exportNum: 300
@@ -43,11 +43,11 @@ spring:
 #    encoding: UTF-8
   # 配置RabbitMQ服务器>>>>>>单机配置
   rabbitmq:
-    host: 120.79.86.50
+    host: 111.229.112.155
     port: 5672
-    username: zl
-    password: 123456
-    virtual-host: /
+    username: admin
+    password: AirportAdmin2023+
+    virtual-host: /airport
     listener: #开启消费者确认机制
       simple:
         # 每次从RabbitMQ获取的消息数量

+ 39 - 1
airport/jeecg-boot-module-system/src/test/java/org/jeecg/SecurityToolsTest.java

@@ -1,13 +1,17 @@
 package org.jeecg;
 
 import com.alibaba.fastjson.JSONObject;
+import com.rabbitmq.client.*;
 import org.jeecg.common.util.security.SecurityTools;
 import org.jeecg.common.util.security.entity.*;
 import org.junit.Test;
 
+import java.io.IOException;
+import java.util.concurrent.TimeoutException;
+
 public class SecurityToolsTest {
     @Test
-    public void Test(){
+    public void Test() {
         MyKeyPair mkeyPair = SecurityTools.generateKeyPair();
 
         JSONObject msg = new JSONObject();
@@ -46,4 +50,38 @@ public class SecurityToolsTest {
         //sucess 为验签成功失败标志 true代码验签成功,false代表失败
         System.out.println(JSONObject.toJSON(securityResp));
     }
+
+    @Test
+    public void sendMq() throws IOException, TimeoutException {
+        // 交换器
+        String EXCHANGE_NAME = "acdm.direct";
+        // 路由密钥
+        String ROUTING_KEY = "acdmMsg";
+        // 队列
+        String QUEUE_NAME = "acdmMsg";
+        // 虚拟主机
+        String VIRTUAL_HOST = "/airport";
+        // RabbitMQ IP
+        String IP_ADDRESS = "111.229.112.155";
+        //RabbitMQ 端口号 5672
+        int PORT = 5672;
+        String USER_NAME = "airport";
+        String PASSWORD = "airport2023$!";
+
+        ConnectionFactory factory = new ConnectionFactory();
+        factory.setHost(IP_ADDRESS);
+        factory.setPort(PORT);
+        factory.setUsername(USER_NAME);
+        factory.setPassword(PASSWORD);
+        factory.setVirtualHost(VIRTUAL_HOST);
+        Connection connection = factory.newConnection(); //创建连接
+        Channel channel = connection.createChannel(); //创建信道
+        //channel.queueDeclare(QUEUE_NAME, true, false, false, null);
+        //发送一条持久化的信息
+        String message = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><MSG><META><SNDR>AFOC</SNDR><RCVR/><REFE>AFOC</REFE><SEQN>120398</SEQN><DDTM>20230729024217</DDTM><TYPE>DFME</TYPE><STYP>STLS</STYP></META><DFLT><FLID>2454381</FLID><FFID>MF-8546-20230729034000-D</FFID><FLTK>A/N</FLTK><FATT>2403</FATT><STLS/></DFLT></MSG>";
+        channel.basicPublish(EXCHANGE_NAME, ROUTING_KEY, MessageProperties.PERSISTENT_TEXT_PLAIN, message.getBytes());
+        //关闭资源
+        channel.close();
+        connection.close();
+    }
 }