mark
このコミットが含まれているのは:
コミット
435c57034e
@ -9,8 +9,11 @@ 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.common.Header;
|
||||
import com.qgs.dc.mq.entity.common.Returns;
|
||||
import com.qgs.dc.mq.entity.specificBody.QueryEQStatusBody;
|
||||
import com.qgs.dc.mq.producer.component.RabbitSender;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import com.rabbitmq.client.Return;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||
@ -32,11 +35,12 @@ import java.util.List;
|
||||
* Ctrl+R 替换设备名
|
||||
*/
|
||||
@Component
|
||||
public class PID10_1Received {
|
||||
public class PID10_1Received{
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(PID10_1Received.class);
|
||||
|
||||
|
||||
@Autowired
|
||||
RabbitSender rabbitSender;
|
||||
|
||||
@Autowired
|
||||
MQMessageHandler mqMessageHandler;
|
||||
@ -59,6 +63,9 @@ public class PID10_1Received {
|
||||
System.out.println("收到的消息是: "+mqMessage.toString());
|
||||
System.out.println();
|
||||
logger.info(mqMessage.toString());
|
||||
//todo reply
|
||||
reply(mqMessage);
|
||||
|
||||
channel.basicAck(deliveryTag,false);
|
||||
System.out.println(mqMessage.toString());
|
||||
}catch (Exception e){
|
||||
@ -70,6 +77,24 @@ public class PID10_1Received {
|
||||
|
||||
}
|
||||
|
||||
public void reply(MQMessage request) throws Exception {
|
||||
MQMessage response = new MQMessage();
|
||||
|
||||
Header header = request.getHeader();
|
||||
header.setFrom("mes");
|
||||
header.setTo("eap");
|
||||
header.setMessageType("Response");
|
||||
header.setSendTimestamp(CommonFunction.getNowDate(1));
|
||||
Returns aReturn = new Returns("0","0");
|
||||
|
||||
response.setHeader(header);
|
||||
response.setReturns(aReturn);
|
||||
|
||||
rabbitSender.sendDirect(response,ConfigOfPID10_1.EXCHANGE_NAME_PID10_1,ConfigOfPID10_1.EAP_RESPONSE_QUEUE_ROUTINGKEY_PID10_1);
|
||||
System.out.println("reply: "+response.toString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
// @RabbitListener(queues = ConfigOfPID10_1.MES_REQUEST_QUEUE_PID10_1)
|
||||
// @RabbitHandler
|
||||
|
@ -5,6 +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;
|
||||
|
@ -5,6 +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;
|
||||
|
@ -15,10 +15,13 @@ import java.util.HashMap;
|
||||
* @DATE: 2021/8/12 15:38
|
||||
*/
|
||||
@Data
|
||||
@JSONType(orders={"header","body","returns"})
|
||||
@JSONType(orders={"header","body","return"})
|
||||
public class MQMessage {
|
||||
private Header header;
|
||||
@JSONField(jsonDirect = true)
|
||||
private String body;
|
||||
@JSONField(name = "return")
|
||||
private Returns returns;
|
||||
|
||||
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.qgs.dc.mq.entity.common;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.alibaba.fastjson.annotation.JSONType;
|
||||
import lombok.Data;
|
||||
|
||||
@ -9,29 +10,15 @@ import lombok.Data;
|
||||
* @DATE: 2021/8/12 15:35
|
||||
*/
|
||||
@Data
|
||||
@JSONType(orders={"returnCode","ReasonCode"})
|
||||
@JSONType(orders={"ReturnCode","ReasonCode"})
|
||||
public class Returns {
|
||||
private String returnCode;
|
||||
@JSONField(name = "ReturnCode")
|
||||
private String ReturnCode;
|
||||
@JSONField(name = "ReasonCode")
|
||||
private String ReasonCode;
|
||||
|
||||
public String getReturnCode() {
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
public void setReturnCode(String returnCode) {
|
||||
this.returnCode = returnCode;
|
||||
}
|
||||
|
||||
public String getReasonCode() {
|
||||
return ReasonCode;
|
||||
}
|
||||
|
||||
public void setReasonCode(String reasonCode) {
|
||||
ReasonCode = reasonCode;
|
||||
}
|
||||
|
||||
public Returns(String returnCode, String reasonCode) {
|
||||
this.returnCode = returnCode;
|
||||
ReturnCode = returnCode;
|
||||
ReasonCode = reasonCode;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ package com.qgs.dc.mq.producer.component;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.qgs.dc.common.utils.CommonFunction;
|
||||
import com.qgs.dc.mq.entity.MQMessage;
|
||||
import com.qgs.dc.mq.entity.common.Header;
|
||||
import com.qgs.dc.mq.entity.common.Returns;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -17,6 +19,7 @@ import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.messaging.support.MessageBuilder;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.sql.SQLOutput;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
@ -190,12 +193,13 @@ public class RabbitSender {
|
||||
cd
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void sendDirect(MQMessage mqMessage, String exchange, String routingKey) throws Exception{
|
||||
|
||||
System.out.println("(before)mqMessage: "+mqMessage.toString());
|
||||
byte[] message = JSONObject.toJSONBytes(mqMessage);
|
||||
|
||||
System.out.println("(after)mqMessage: "+new String(message));
|
||||
String transitionId = mqMessage.getHeader().getTransactionId();
|
||||
CorrelationData cd = new CorrelationData(transitionId);
|
||||
rabbitTemplate.setConfirmCallback(confirmCallback);
|
||||
|
読み込み中…
新しいイシューから参照
ユーザーをブロックする