1 Star 0 Fork 0

xlizy/common-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
xmq.go 1.22 KB
一键复制 编辑 原始数据 按行查看 历史
xlizy 提交于 2024-04-09 16:16 . init
package xmq
import (
"context"
config2 "gitee.com/xlizy/common-go/base/config"
"gitee.com/xlizy/common-go/base/enums/common_error"
"gitee.com/xlizy/common-go/base/response"
"gitee.com/xlizy/common-go/components/dubbo"
"gitee.com/xlizy/common-go/utils/common"
"gitee.com/xlizy/common-go/utils/zlog"
rpcApi "gitee.com/xlizy/rpc-interface/pbs"
)
var MQServiceClientImpl = new(rpcApi.MQServiceClientImpl)
func GetMQConsume() dubbo.Service {
return dubbo.Service{
Name: "MQServiceClientImpl",
InterfaceName: "com.rehod.mq.MQServiceClientImpl",
Interface: MQServiceClientImpl,
}
}
func Send(topic, msg string) *response.Response {
zlog.Info("发送MQ消息,topic:{},msg:{}", topic, msg)
rsp, err := MQServiceClientImpl.SendMQ(context.TODO(), &rpcApi.SendMQReq{
Topic: topic,
Msg: msg,
ClientIp: common.GetLocalPriorityIp(config2.PriorityNetwork.Networks),
AppName: config2.GetNacosCfg().AppName,
})
if err != nil {
zlog.Error("发送MQ失败:{}", err.Error())
return response.Error(common_error.RPC_CALL_ERROR, nil)
}
if rsp.Success {
zlog.Error("发送MQ成功")
return response.Succ()
} else {
zlog.Error("发送MQ失败:{}", rsp.Msg)
return response.ErrorCus(rsp.Code, rsp.Msg, nil)
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/xlizy/common-go.git
git@gitee.com:xlizy/common-go.git
xlizy
common-go
common-go
v0.1.3

搜索帮助