zhou.xiaoning 2 anni fa
parent
commit
af6c4474f5
3 ha cambiato i file con 4 aggiunte e 5 eliminazioni
  1. 1 1
      initialize/rabbitmq.go
  2. 2 1
      model/mq/request/mq.go
  3. 1 3
      service/mq/mq.go

+ 1 - 1
initialize/rabbitmq.go

@@ -72,6 +72,7 @@ func (t *MQProc) Process(topic, queuename string, msg *[]byte) {
 				asyncTask := c.GetAsyncTask(key)
 				if asyncTask != nil {
 					rspData := string(*bytes)
+					global.M2A_LOG.Info("[S->C]", zap.Any("rsp", funcode), zap.Any("sessionId", sessionId), zap.Any("data", string(rspData)))
 					// 判断是否要加密
 					if asyncTask.IsEncrypted {
 						if b, err := packet.Encrypt(*bytes, packet.AESKey, true); err != nil {
@@ -82,7 +83,6 @@ func (t *MQProc) Process(topic, queuename string, msg *[]byte) {
 						}
 					}
 					// 给客户端回调
-					global.M2A_LOG.Info("[S->C]", zap.Any("rsp", funcode), zap.Any("sessionId", sessionId), zap.Any("data", string(rspData)))
 					r := rsp.MQBodyRsp{
 						FunCode:     funcode,
 						IsEncrypted: asyncTask.IsEncrypted,

+ 2 - 1
model/mq/request/mq.go

@@ -25,7 +25,7 @@ type MQBodyReq struct {
 // GetProtoBytes 将客户端请求的数据转换成总线使用的Protobuf
 //
 // serialNumber 流水号
-func (r *MQBodyReq) GetProtoBytes(serialNumber *uint32) (bytes *[]byte, err error) {
+func (r *MQBodyReq) GetProtoBytes(serialNumber *uint32, sessionId string) (bytes *[]byte, err error) {
 	// 判断是否需要解密数据内容
 	data := r.Data
 	if *r.IsEncrypted {
@@ -44,6 +44,7 @@ func (r *MQBodyReq) GetProtoBytes(serialNumber *uint32) (bytes *[]byte, err erro
 		}
 		data = string(p)
 	}
+	global.M2A_LOG.Info("[C->S]", zap.Any("req", r.FunCodeReq), zap.Any("SessionId", sessionId), zap.Any("data", data))
 
 	// JSON -> Protobuf
 	switch int(r.FunCodeReq) {

+ 1 - 3
service/mq/mq.go

@@ -37,7 +37,7 @@ func SendMQ(c *gin.Context, req *request.MQBodyReq) (err error) {
 
 	// 将客户端请求的数据转换成总线使用的Protobuf
 	serialNumber := t.GetSerialNumber()
-	bytes, err := req.GetProtoBytes(&serialNumber)
+	bytes, err := req.GetProtoBytes(&serialNumber, t.SessionID)
 	if err != nil {
 		return
 	}
@@ -81,8 +81,6 @@ func SendMQ(c *gin.Context, req *request.MQBodyReq) (err error) {
 	}
 	go rabbitmq.Publish(topic, packet)
 
-	global.M2A_LOG.Info("[C->S]", zap.Any("req", req.FunCodeReq), zap.Any("SessionId", packet.SessionId), zap.Any("data", req.Data))
-
 	// 阻塞线程等待总线回复或超时
 	// 这里make时没有指定长度,所以是发送者与接收者的同步操作,发送者会阻塞,所以一般会在下面使用超时来解锁。
 	asyncTask.Rsp = make(chan response.MQBodyRsp)