parent
af020e8452
commit
6bf4ab7b20
20
mq.go
20
mq.go
@ -53,15 +53,17 @@ func (s MQSession) Open() error {
|
||||
s.MQConnection.Close()
|
||||
return err
|
||||
}
|
||||
s.MQDelivery, err = s.MQChannel.Consume(
|
||||
s.MQQueue.Name, // queue
|
||||
"", // consumer
|
||||
true, // auto-ack
|
||||
false, // exclusive
|
||||
false, // no-local
|
||||
false, // no-wait
|
||||
nil, // args
|
||||
)
|
||||
/*
|
||||
s.MQDelivery, err = s.MQChannel.Consume(
|
||||
s.MQQueue.Name, // queue
|
||||
"", // consumer
|
||||
true, // auto-ack
|
||||
false, // exclusive
|
||||
false, // no-local
|
||||
false, // no-wait
|
||||
nil, // args
|
||||
)
|
||||
*/
|
||||
logOnError(err, "Open : Failed to register a consumer")
|
||||
if err != nil {
|
||||
s.MQChannel.Close()
|
||||
|
22
workers.go
22
workers.go
@ -33,18 +33,16 @@ func MQGetMsgWorker(id int, msgs chan<- ChatWarsMessage) {
|
||||
}
|
||||
log.Printf("MQGetMsgWorker[" + strconv.Itoa(id) + "] : Connected to RabbitMQ")
|
||||
log.Printf("MQGetMsgWorker["+strconv.Itoa(id)+"] : Session address : %p.\n", &s)
|
||||
/*
|
||||
m, err := s.MQChannel.Consume(
|
||||
s.Queue, // queue
|
||||
"", // consumer
|
||||
true, // auto-ack
|
||||
false, // exclusive
|
||||
false, // no-local
|
||||
false, // no-wait
|
||||
nil, // args
|
||||
)
|
||||
*/
|
||||
for d := range s.MQDelivery {
|
||||
m, err := s.MQChannel.Consume(
|
||||
s.Queue, // 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))
|
||||
|
Loading…
Reference in New Issue
Block a user