test
This commit is contained in:
parent
30858db212
commit
6b7cb32bbc
20
mq.go
20
mq.go
@ -53,17 +53,15 @@ 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
|
true, // auto-ack
|
||||||
true, // auto-ack
|
false, // exclusive
|
||||||
false, // exclusive
|
false, // no-local
|
||||||
false, // no-local
|
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()
|
||||||
|
22
workers.go
22
workers.go
@ -33,16 +33,18 @@ 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(
|
/*
|
||||||
s.Queue, // queue
|
m, err := s.MQChannel.Consume(
|
||||||
"", // consumer
|
s.Queue, // queue
|
||||||
true, // auto-ack
|
"", // consumer
|
||||||
false, // exclusive
|
true, // auto-ack
|
||||||
false, // no-local
|
false, // exclusive
|
||||||
false, // no-wait
|
false, // no-local
|
||||||
nil, // args
|
false, // no-wait
|
||||||
)
|
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))
|
||||||
|
Loading…
Reference in New Issue
Block a user