This commit is contained in:
shoopea 2019-06-28 14:38:48 +08:00
parent 30858db212
commit 6b7cb32bbc
2 changed files with 21 additions and 21 deletions

2
mq.go
View File

@ -53,7 +53,6 @@ func (s MQSession) Open() error {
s.MQConnection.Close() s.MQConnection.Close()
return err return err
} }
/*
s.MQDelivery, err = s.MQChannel.Consume( s.MQDelivery, err = s.MQChannel.Consume(
s.MQQueue.Name, // queue s.MQQueue.Name, // queue
"", // consumer "", // consumer
@ -63,7 +62,6 @@ func (s MQSession) Open() error {
false, // no-wait false, // no-wait
nil, // args nil, // args
) )
*/
logOnError(err, "Open : Failed to register a consumer") logOnError(err, "Open : Failed to register a consumer")
if err != nil { if err != nil {
s.MQChannel.Close() s.MQChannel.Close()

View File

@ -33,6 +33,7 @@ func MQGetMsgWorker(id int, msgs chan<- ChatWarsMessage) {
} }
log.Printf("MQGetMsgWorker[" + strconv.Itoa(id) + "] : Connected to RabbitMQ") log.Printf("MQGetMsgWorker[" + strconv.Itoa(id) + "] : Connected to RabbitMQ")
log.Printf("MQGetMsgWorker["+strconv.Itoa(id)+"] : Session address : %p.\n", &s) log.Printf("MQGetMsgWorker["+strconv.Itoa(id)+"] : Session address : %p.\n", &s)
/*
m, err := s.MQChannel.Consume( m, err := s.MQChannel.Consume(
s.Queue, // queue s.Queue, // queue
"", // consumer "", // consumer
@ -42,7 +43,8 @@ func MQGetMsgWorker(id int, msgs chan<- ChatWarsMessage) {
false, // no-wait false, // no-wait
nil, // args nil, // args
) )
for d := range m { */
for d := range s.MQDelivery {
log.Printf("MQGetMsgWorker["+strconv.Itoa(id)+"] : Received a message: %s", string(d.Body)) log.Printf("MQGetMsgWorker["+strconv.Itoa(id)+"] : Received a message: %s", string(d.Body))
err = json.Unmarshal(d.Body, &x) err = json.Unmarshal(d.Body, &x)
logOnError(err, "MQGetMsgWorker["+strconv.Itoa(id)+"] : Can't unmarshal.\n"+string(d.Body)) logOnError(err, "MQGetMsgWorker["+strconv.Itoa(id)+"] : Can't unmarshal.\n"+string(d.Body))