Go中使用RabbitMQ
go
2022-02-10 12:39
476
0
(
)
(
rabbitUrl Conn *.Connection
)
RabbitMQ {
queueName routeKey exchangeName exchangeType virtualHost connection *.Connection
channel *.Channel
foreverChan }
QueueExchange {
QueueName RouteKey ExchangeName ExchangeType }
Producer {
() () }
Consumer {
(delivery *.Delivery)
() }
(*) () *.Connection {
.connection.IsClosed() {
.connection.channel = ()
}
.connection
}
(*) () *.Channel {
.channel
}
(*) () {
.foreverChan
}
() {
(
ip = .Config.String()
username = .Config.String()
password = .Config.String()
port = .Config.DefaultInt()
vhost = .Config.DefaultString()
)
vhost == {
rabbitUrl = .(usernamepasswordipport)
} {
rabbitUrl = .(usernamepasswordipportvhost)
}
}
() *{
connectionchannel := ()
mq := &{connection: connectionchannel: channel}
mq.foreverChan = ()
mq
}
() (*.Connection*.Channel) {
connectionerr := .Dial(rabbitUrl)
err != {
.(err)
}
channelerr := connection.Channel()
err != {
.()
}
connectionchannel
}