This commit is contained in:
shoopea 2019-06-28 14:18:56 +08:00
parent bb7587b7f9
commit 002c547a50

View File

@ -32,8 +32,16 @@ func MQGetMsgWorker(id int, msgs chan<- ChatWarsMessage) {
err = s.Open()
}
log.Printf("MQGetMsgWorker[" + strconv.Itoa(id) + "] : Connected to RabbitMQ")
for d := range s.MQDelivery {
m, err := s.MQChannel.Consume(
s.MQQueue.Name, // queue
"", // consumer
true, // auto-ack
false, // exclusive
false, // no-local
false, // no-wait
nil, // args
)
for d := range m {
log.Printf("MQGetMsgWorker["+strconv.Itoa(id)+"] : Received a message: %s", string(d.Body))
err = json.Unmarshal(d.Body, &x)
logOnError(err, "MQGetMsgWorker["+strconv.Itoa(id)+"] : Can't unmarshal.\n"+string(d.Body))
@ -352,7 +360,16 @@ func MQKeepAliveWorker() {
time.Sleep(15 * time.Second)
err = s.Open()
}
for d := range s.MQDelivery {
m, err := s.MQChannel.Consume(
s.MQQueue.Name, // queue
"", // consumer
true, // auto-ack
false, // exclusive
false, // no-local
false, // no-wait
nil, // args
)
for d := range m {
log.Printf("MQKeepAliveWorker : Received a message: %s", string(d.Body))
x := MQKeepAlive{}
err = json.Unmarshal(d.Body, &x)