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