test
This commit is contained in:
parent
bb7587b7f9
commit
002c547a50
23
workers.go
23
workers.go
@ -32,8 +32,16 @@ func MQGetMsgWorker(id int, msgs chan<- ChatWarsMessage) {
|
|||||||
err = s.Open()
|
err = s.Open()
|
||||||
}
|
}
|
||||||
log.Printf("MQGetMsgWorker[" + strconv.Itoa(id) + "] : Connected to RabbitMQ")
|
log.Printf("MQGetMsgWorker[" + strconv.Itoa(id) + "] : Connected to RabbitMQ")
|
||||||
|
m, err := s.MQChannel.Consume(
|
||||||
for d := range s.MQDelivery {
|
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))
|
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))
|
||||||
@ -352,7 +360,16 @@ func MQKeepAliveWorker() {
|
|||||||
time.Sleep(15 * time.Second)
|
time.Sleep(15 * time.Second)
|
||||||
err = s.Open()
|
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))
|
log.Printf("MQKeepAliveWorker : Received a message: %s", string(d.Body))
|
||||||
x := MQKeepAlive{}
|
x := MQKeepAlive{}
|
||||||
err = json.Unmarshal(d.Body, &x)
|
err = json.Unmarshal(d.Body, &x)
|
||||||
|
Loading…
Reference in New Issue
Block a user