[agent-go] 解决代码bug

This commit is contained in:
zeaslity
2023-03-24 17:02:28 +08:00
parent 7e2450d30a
commit 5accd999f8
8 changed files with 44 additions and 37 deletions

View File

@@ -1,7 +1,6 @@
package rabbitmq
import (
"agent-go/g"
"fmt"
"github.com/streadway/amqp"
)
@@ -23,6 +22,7 @@ type ConnectProperty struct {
func Send(conn *RabbitMQConn, connProp *ConnectProperty, message []byte) {
// 往哪里发
channel := conn.Channel
// 发送
channel.Publish(
connProp.ExchangeName,
@@ -43,13 +43,13 @@ func Read(conn *RabbitMQConn, connProp *ConnectProperty, autoAck bool) <-chan am
// 开始读取队列中的全部消息
msgs, err := channel.Consume(
connProp.QueueName, // 队列名称
g.G.AgentServerInfo.AgentTopicName, // 消费者名称
autoAck, // auto-ack
false, // exclusive
false, // no-local
false, // no-wait
nil, // arguments
connProp.QueueName, // 队列名称
"", // 消费者名称
autoAck, // auto-ack
false, // exclusive
false, // no-local
false, // no-wait
nil, // arguments
)
if err != nil {
log.Error(fmt.Sprintf("Failed to register a consumer: %v", err))