Files
kami_gateway/internal/service/message/send_message.go
danial e88ff05a14 refactor(trace): 重命名 otel 包为 otelTrace并更新相关引用
- 将内部使用的 otel 包重命名为 otelTrace
- 更新了所有引用该包的文件中的导入路径
- 修改了部分函数和变量名称以适应新的包名
2025-02-23 21:56:29 +08:00

27 lines
641 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package message
import (
"context"
"fmt"
"gateway/internal/otelTrace"
"os"
"go.uber.org/zap"
)
func SendMessage(ctx context.Context, topic, message string) {
conn := GetActiveMQConn()
if conn == nil {
otelTrace.Logger.WithContext(ctx).Error("send message get Active mq fail")
os.Exit(1)
}
err := conn.Send(topic, "text/plain", []byte(message))
if err != nil {
otelTrace.Logger.WithContext(ctx).Error("发送消息给activeMQ失败, message=", zap.String("message", message))
} else {
otelTrace.Logger.WithContext(ctx).Info(fmt.Sprintf("发送消息给activeMQ成功message="), zap.String("message", message))
}
}