[agent-go] 完成RabbitMQ连接部分的代码
This commit is contained in:
20
agent-go/rabbitmq/MessageSender.go
Normal file
20
agent-go/rabbitmq/MessageSender.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package rabbitmq
|
||||
|
||||
import "github.com/streadway/amqp"
|
||||
|
||||
// Send 向RabbitMQ中发送消息
|
||||
func Send(conn *RabbitMQConn, connProp *ConnectProperty, message []byte) {
|
||||
// 往哪里发
|
||||
channel := conn.Channel
|
||||
// 发送
|
||||
channel.Publish(
|
||||
connProp.ExchangeName,
|
||||
connProp.TopicKey,
|
||||
false,
|
||||
true,
|
||||
amqp.Publishing{
|
||||
ContentType: "text/plain",
|
||||
Body: message,
|
||||
},
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user