|
@@ -3,16 +3,19 @@ package initialize
|
|
|
import (
|
|
import (
|
|
|
"encoding/base64"
|
|
"encoding/base64"
|
|
|
"fmt"
|
|
"fmt"
|
|
|
|
|
+ "mtp20access/client"
|
|
|
"mtp20access/global"
|
|
"mtp20access/global"
|
|
|
rsp "mtp20access/model/mq/response"
|
|
rsp "mtp20access/model/mq/response"
|
|
|
"mtp20access/packet"
|
|
"mtp20access/packet"
|
|
|
|
|
+ "mtp20access/rabbitmq"
|
|
|
"mtp20access/res/pb"
|
|
"mtp20access/res/pb"
|
|
|
"mtp20access/utils"
|
|
"mtp20access/utils"
|
|
|
|
|
|
|
|
- "github.com/golang/protobuf/proto"
|
|
|
|
|
|
|
+ // "github.com/golang/protobuf/proto"
|
|
|
"github.com/streadway/amqp"
|
|
"github.com/streadway/amqp"
|
|
|
"go.uber.org/zap"
|
|
"go.uber.org/zap"
|
|
|
"google.golang.org/protobuf/encoding/protojson"
|
|
"google.golang.org/protobuf/encoding/protojson"
|
|
|
|
|
+ "google.golang.org/protobuf/proto"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
func RabbitMQ() *global.RabbitMQ {
|
|
func RabbitMQ() *global.RabbitMQ {
|
|
@@ -48,7 +51,7 @@ func (t *MQProc) Process(topic, queuename string, msg *[]byte) {
|
|
|
|
|
|
|
|
if funcode, sessionId, bytes, serialNumber, err := t.getRspProtobuf(msg); err == nil && bytes != nil {
|
|
if funcode, sessionId, bytes, serialNumber, err := t.getRspProtobuf(msg); err == nil && bytes != nil {
|
|
|
// 尝试获取对应异步任务
|
|
// 尝试获取对应异步任务
|
|
|
- if client, exists := global.M2A_Clients[int(sessionId)]; exists {
|
|
|
|
|
|
|
+ if client, exists := client.Clients[int(sessionId)]; exists {
|
|
|
key := fmt.Sprintf("%v_%v_%v", sessionId, funcode, serialNumber)
|
|
key := fmt.Sprintf("%v_%v_%v", sessionId, funcode, serialNumber)
|
|
|
// 银行服务相关的回复流水号是错误的,所以需要特殊处理
|
|
// 银行服务相关的回复流水号是错误的,所以需要特殊处理
|
|
|
if int(funcode) == global.T2bBankSignRsp ||
|
|
if int(funcode) == global.T2bBankSignRsp ||
|
|
@@ -520,57 +523,57 @@ func (t *MQProc) getRspProtobuf(msg *[]byte) (funcode uint32, sessionId uint32,
|
|
|
// RabbitMQSubscribeTopic 订阅主题
|
|
// RabbitMQSubscribeTopic 订阅主题
|
|
|
func RabbitMQSubscribeTopic() (err error) {
|
|
func RabbitMQSubscribeTopic() (err error) {
|
|
|
// 订阅需要的总线响应主题
|
|
// 订阅需要的总线响应主题
|
|
|
- if err = global.SubscribeTopic(global.TOPIC_RSP_QKERNEL); err != nil {
|
|
|
|
|
|
|
+ if err = rabbitmq.SubscribeTopic(global.TOPIC_RSP_QKERNEL); err != nil {
|
|
|
global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
|
|
global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- if err = global.SubscribeTopic(global.TOPIC_MANAGE_RSP); err != nil {
|
|
|
|
|
|
|
+ if err = rabbitmq.SubscribeTopic(global.TOPIC_MANAGE_RSP); err != nil {
|
|
|
global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
|
|
global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- if err = global.SubscribeTopic(global.TOPIC_RSP_BANK); err != nil {
|
|
|
|
|
|
|
+ if err = rabbitmq.SubscribeTopic(global.TOPIC_RSP_BANK); err != nil {
|
|
|
global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
|
|
global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- if err = global.SubscribeTopic(global.TOPIC_RSP_MONEY); err != nil {
|
|
|
|
|
|
|
+ if err = rabbitmq.SubscribeTopic(global.TOPIC_RSP_MONEY); err != nil {
|
|
|
global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
|
|
global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- if err = global.SubscribeTopic(global.TOPIC_PERFORMANCE_RSP); err != nil {
|
|
|
|
|
|
|
+ if err = rabbitmq.SubscribeTopic(global.TOPIC_PERFORMANCE_RSP); err != nil {
|
|
|
global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
|
|
global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- if err = global.SubscribeTopic(global.TOPIC_WAREHOUSE_RECIEPT_RSP); err != nil {
|
|
|
|
|
|
|
+ if err = rabbitmq.SubscribeTopic(global.TOPIC_WAREHOUSE_RECIEPT_RSP); err != nil {
|
|
|
global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
|
|
global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- if err = global.SubscribeTopic(global.TOPIC_RSP_WAREHOUSE_TRADE); err != nil {
|
|
|
|
|
|
|
+ if err = rabbitmq.SubscribeTopic(global.TOPIC_RSP_WAREHOUSE_TRADE); err != nil {
|
|
|
global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
|
|
global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- if err = global.SubscribeTopic(global.TOPIC_RSP_WAREHOUSE_TRADE_GZ); err != nil {
|
|
|
|
|
|
|
+ if err = rabbitmq.SubscribeTopic(global.TOPIC_RSP_WAREHOUSE_TRADE_GZ); err != nil {
|
|
|
global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
|
|
global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- if err = global.SubscribeTopic(global.TOPIC_RSP_CJBS_TRADE_GZ); err != nil {
|
|
|
|
|
|
|
+ if err = rabbitmq.SubscribeTopic(global.TOPIC_RSP_CJBS_TRADE_GZ); err != nil {
|
|
|
global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
|
|
global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 铁合金
|
|
// 铁合金
|
|
|
- if err = global.SubscribeTopic(global.TOPIC_RSP_WAREHOUSE_PRESALE_THJ); err != nil {
|
|
|
|
|
|
|
+ if err = rabbitmq.SubscribeTopic(global.TOPIC_RSP_WAREHOUSE_PRESALE_THJ); err != nil {
|
|
|
global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
|
|
global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- if err = global.SubscribeTopic(global.TOPIC_MANAGER_THJ_NTF); err != nil {
|
|
|
|
|
|
|
+ if err = rabbitmq.SubscribeTopic(global.TOPIC_MANAGER_THJ_NTF); err != nil {
|
|
|
global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
|
|
global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- if err = global.SubscribeTopic(global.TOPIC_RSP_WAREHOUSE_PRESALE_GZ); err != nil {
|
|
|
|
|
|
|
+ if err = rabbitmq.SubscribeTopic(global.TOPIC_RSP_WAREHOUSE_PRESALE_GZ); err != nil {
|
|
|
global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
|
|
global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- if err = global.SubscribeTopic(global.TOPIC_RSP_WAREHOUSE_CENTERPURCHASE_GZ); err != nil {
|
|
|
|
|
|
|
+ if err = rabbitmq.SubscribeTopic(global.TOPIC_RSP_WAREHOUSE_CENTERPURCHASE_GZ); err != nil {
|
|
|
global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
|
|
global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
@@ -585,8 +588,8 @@ func StartRabbitMQReceive() {
|
|
|
t := &MQProc{}
|
|
t := &MQProc{}
|
|
|
|
|
|
|
|
go func() {
|
|
go func() {
|
|
|
- for _, subinfo := range global.SubInfos {
|
|
|
|
|
- global.Receive(subinfo.Topic, subinfo.QueueName, t)
|
|
|
|
|
|
|
+ for _, subinfo := range rabbitmq.SubInfos {
|
|
|
|
|
+ rabbitmq.Receive(subinfo.Topic, subinfo.QueueName, t)
|
|
|
}
|
|
}
|
|
|
}()
|
|
}()
|
|
|
}
|
|
}
|