From a254bd62a6be7f0c6da457d82680f6f39f34dca4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8E=E8=BF=9E=E7=90=9B?= <1059178422@qq.com> Date: Fri, 25 Nov 2022 14:56:35 +0800 Subject: [PATCH] =?UTF-8?q?PID10=E4=BA=8B=E4=BB=B6=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../qgs/dc/mq/consumer/PID10_1Received.java | 28 ++++++++++--------- .../com/qgs/dc/mq/consumer/PID18Received.java | 2 +- .../qgs/dc/mq/consumer/PID2_1Received.java | 5 +++- .../com/qgs/dc/mq/consumer/PID4BReceived.java | 2 +- .../com/qgs/dc/mq/entity/MQToMesMessage.java | 27 ++++++++++++++++++ src/main/resources/application.yml | 3 +- 6 files changed, 50 insertions(+), 17 deletions(-) create mode 100644 src/main/java/com/qgs/dc/mq/entity/MQToMesMessage.java diff --git a/src/main/java/com/qgs/dc/mq/consumer/PID10_1Received.java b/src/main/java/com/qgs/dc/mq/consumer/PID10_1Received.java index 6c19f6e..1857f30 100644 --- a/src/main/java/com/qgs/dc/mq/consumer/PID10_1Received.java +++ b/src/main/java/com/qgs/dc/mq/consumer/PID10_1Received.java @@ -8,6 +8,7 @@ import com.qgs.dc.mq.Constant.Constant; import com.qgs.dc.mq.configuration.ConfigOfPID10_1; import com.qgs.dc.mq.consumer.commonHandler.MQMessageHandler; import com.qgs.dc.mq.entity.MQMessage; +import com.qgs.dc.mq.entity.MQToMesMessage; import com.qgs.dc.mq.entity.common.Header; import com.qgs.dc.mq.entity.common.Returns; import com.qgs.dc.mq.entity.specificBody.QueryEQStatusBody; @@ -66,23 +67,24 @@ public class PID10_1Received{ reply(mqMessage); // //回调给MES --- 开始 -// //1. 正常情况 -// String integer= HttpUtil.post(Constant.mesCallBackUrl,JSONObject.toJSONString(mqMessage)); -// Integer result = Integer.valueOf(integer); -// -// //注意 这里特别注意 已经拒收的消息 再签收是要出错的,这里要特别注意。 -// if(result == 1){ -// logger.info("在 EAP_REQUEST_QUEUE_PID4B 队列中,transitionId"+transactionId+", 这条消息处理成功"); -// channel.basicAck(deliveryTag,false); -// }else { -// logger.error("在 EAP_REQUEST_QUEUE_PID4B 队列中,transitionId"+transactionId+" 处理消息的时候 出现异常,然后 拒签消息 ,然后丢到死信队列"); -// channel.basicNack(deliveryTag,false,false); -// } + //1. 正常情况 + MQToMesMessage mqToMesMessage = new MQToMesMessage(mqMessage.getHeader(),mqMessage.getBody(),mqMessage.getReturns()); + String integer= HttpUtil.post(Constant.mesCallBackUrl,JSONObject.toJSONString(mqToMesMessage)); + Integer result = Integer.valueOf(integer); + + //注意 这里特别注意 已经拒收的消息 再签收是要出错的,这里要特别注意。 + if(result == 1){ + logger.info("在 EAP_REQUEST_QUEUE_PID4B 队列中,transitionId"+transactionId+", 这条消息处理成功"); + channel.basicAck(deliveryTag,false); + }else { + logger.error("在 EAP_REQUEST_QUEUE_PID4B 队列中,transitionId"+transactionId+" 处理消息的时候 出现异常,然后 拒签消息 ,然后丢到死信队列"); + channel.basicNack(deliveryTag,false,false); + } // //回调给MES --- 结束 - channel.basicAck(deliveryTag,false); +// channel.basicAck(deliveryTag,false); }catch (Exception e){ // 第一个false 是 不批量签收;第二个false 是 不重回队列 logger.error(e.getMessage()); diff --git a/src/main/java/com/qgs/dc/mq/consumer/PID18Received.java b/src/main/java/com/qgs/dc/mq/consumer/PID18Received.java index b726ec2..d2c3025 100644 --- a/src/main/java/com/qgs/dc/mq/consumer/PID18Received.java +++ b/src/main/java/com/qgs/dc/mq/consumer/PID18Received.java @@ -5,7 +5,7 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.qgs.dc.common.utils.CommonFunction; import com.qgs.dc.mq.Constant.Constant; -import com.qgs.dc.mq.configuration.ConfigOfPID13S; + import com.qgs.dc.mq.configuration.ConfigOfPID18; import com.qgs.dc.mq.consumer.commonHandler.MQMessageHandler; import com.qgs.dc.mq.entity.MQMessage; diff --git a/src/main/java/com/qgs/dc/mq/consumer/PID2_1Received.java b/src/main/java/com/qgs/dc/mq/consumer/PID2_1Received.java index cbdd385..86fb6e3 100644 --- a/src/main/java/com/qgs/dc/mq/consumer/PID2_1Received.java +++ b/src/main/java/com/qgs/dc/mq/consumer/PID2_1Received.java @@ -8,6 +8,7 @@ import com.qgs.dc.mq.Constant.Constant; import com.qgs.dc.mq.configuration.ConfigOfPID2_1; import com.qgs.dc.mq.consumer.commonHandler.MQMessageHandler; import com.qgs.dc.mq.entity.MQMessage; +import com.qgs.dc.mq.entity.MQToMesMessage; import com.qgs.dc.mq.entity.common.Header; import com.qgs.dc.mq.entity.specificBody.QueryEQStatusBody; import com.rabbitmq.client.Channel; @@ -58,7 +59,9 @@ public class PID2_1Received { String transactionId = mqMessage.getHeader().getTransactionId(); //1. 正常情况 //Integer integer = mqMessageHandler.requestHandler(message); - String integer= HttpUtil.post(Constant.mesCallBackUrl,JSONObject.toJSONString(mqMessage)); + MQToMesMessage mqToMesMessage = new MQToMesMessage(mqMessage.getHeader(),mqMessage.getBody(),mqMessage.getReturns()); + + String integer= HttpUtil.post(Constant.mesCallBackUrl,JSONObject.toJSONString(mqToMesMessage)); Integer result = Integer.valueOf(integer); //注意 这里特别注意 已经拒收的消息 再签收是要出错的,这里要特别注意。 diff --git a/src/main/java/com/qgs/dc/mq/consumer/PID4BReceived.java b/src/main/java/com/qgs/dc/mq/consumer/PID4BReceived.java index a30205c..7f31e53 100644 --- a/src/main/java/com/qgs/dc/mq/consumer/PID4BReceived.java +++ b/src/main/java/com/qgs/dc/mq/consumer/PID4BReceived.java @@ -5,7 +5,7 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.qgs.dc.common.utils.CommonFunction; import com.qgs.dc.mq.Constant.Constant; -import com.qgs.dc.mq.configuration.ConfigOfPID13S; + import com.qgs.dc.mq.configuration.ConfigOfPID4B; import com.qgs.dc.mq.consumer.commonHandler.MQMessageHandler; import com.qgs.dc.mq.entity.MQMessage; diff --git a/src/main/java/com/qgs/dc/mq/entity/MQToMesMessage.java b/src/main/java/com/qgs/dc/mq/entity/MQToMesMessage.java new file mode 100644 index 0000000..844cc23 --- /dev/null +++ b/src/main/java/com/qgs/dc/mq/entity/MQToMesMessage.java @@ -0,0 +1,27 @@ +package com.qgs.dc.mq.entity; + +import com.alibaba.fastjson.annotation.JSONField; +import com.alibaba.fastjson.annotation.JSONType; +import com.qgs.dc.mq.entity.common.Header; +import com.qgs.dc.mq.entity.common.Returns; +import lombok.Data; + +/** + * @Desc: "" + * @Author: caixiang + * @DATE: 2021/8/12 15:38 + */ +@Data +@JSONType(orders={"header","body","returns"}) +public class MQToMesMessage { + private Header header; + private String body; + //在序列化和反序列化 的时候 都会把 json 里面的return字段转成 object 里面的returns字段 + private Returns returns; + + public MQToMesMessage(Header header, String body, Returns returns) { + this.header = header; + this.body = body; + this.returns = returns; + } +} \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index afa57ca..cd9a693 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -8,7 +8,8 @@ server: spring: rabbitmq: # 如果是rabbitmq+haproxy+keepalived集群 ,,那么192.168.0.176是haproxy代理的地址(严格来说是keepalived的vip) - addresses: 192.168.0.170:5672 # 新版rabbitmq 版本还未测试 +# addresses: 192.168.0.170:5672 # 新版rabbitmq 版本还未测试 + addresses: 172.16.21.191:5672 #addresses: 172.16.21.133:5672 username: cigs password: cigs