This commit is contained in:
shoopea 2019-06-28 15:26:14 +08:00
parent 09172c9186
commit 48ff558d59

View File

@ -36,32 +36,34 @@ func MQGetMsgWorker(id int, msgs chan<- ChatWarsMessage) {
log.Printf("MQGetMsgWorker["+strconv.Itoa(id)+"] : Connection address : %p.\n", &s.MQConnection)
log.Printf("MQGetMsgWorker["+strconv.Itoa(id)+"] : Channel address : %p.\n", &s.MQChannel)
log.Printf("MQGetMsgWorker["+strconv.Itoa(id)+"] : Queue name : %s.\n", s.Queue)
q, err := s.MQChannel.QueueDeclare(
s.Queue, // name
false, // durable
false, // delete when unused
false, // exclusive
false, // no-wait
nil, // arguments
/*
q, err := s.MQChannel.QueueDeclare(
s.Queue, // name
false, // durable
false, // delete when unused
false, // exclusive
false, // no-wait
nil, // arguments
)
m, err := s.MQChannel.Consume(
q.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))
if err == nil {
msgs <- x
)
m, err := s.MQChannel.Consume(
q.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))
if err == nil {
msgs <- x
}
}
}
*/
log.Printf("MQGetMsgWorker[" + strconv.Itoa(id) + "] : Closing queue.\n")
s.Close()
}