26 lines
603 B
Go
26 lines
603 B
Go
|
|
package rebbitMQ
|
|||
|
|
|
|||
|
|
import (
|
|||
|
|
configYaml "common/configsYaml"
|
|||
|
|
"github.com/streadway/amqp"
|
|||
|
|
"goutil/logUtilPlus"
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
// 发送单挑mq消息
|
|||
|
|
func sendMqData(data string) {
|
|||
|
|
|
|||
|
|
// 发布消息到队列
|
|||
|
|
err := RabbitMQChannel.Publish(
|
|||
|
|
"", // 交换机名称
|
|||
|
|
configYaml.GetRabbitMQName(), // 路由键
|
|||
|
|
false, // 是否强制
|
|||
|
|
false, // 是否立即
|
|||
|
|
amqp.Publishing{
|
|||
|
|
ContentType: "text/plain",
|
|||
|
|
Body: []byte(data),
|
|||
|
|
})
|
|||
|
|
if err != nil {
|
|||
|
|
logUtilPlus.ErrorLog("Failed to publish a message,err:%s", err.Error())
|
|||
|
|
}
|
|||
|
|
}
|