| 1234567891011121314151617181920212223242526272829303132 |
- package mq
- import (
- "errors"
- "mtp20access/global"
- "mtp20access/model/mq/request"
- "github.com/gin-gonic/gin"
- )
- // SendNtfMQ 向总线发送通知类信息
- func SendNtfMQ(c *gin.Context, req *request.MQNtfReq) (err error) {
- // 将请求的数据转换成总线使用的Protobuf
- bytes, err := req.GetProtoBytes()
- if err != nil {
- return
- }
- if bytes == nil {
- err = errors.New("请求信息序列化失败")
- return
- }
- // 向总线发送业务信息
- packet := &global.MQPacket{
- FunCode: req.FunCode,
- SessionId: 0,
- Data: bytes,
- }
- go global.Publish(req.Topic, packet)
- return
- }
|