This commit is contained in:
shoopea 2019-05-03 15:45:25 +08:00
parent 8894b7b645
commit 477fad6086
2 changed files with 9 additions and 3 deletions

6
mq.go
View File

@ -44,10 +44,10 @@ func MQMainReceive() {
for d := range msgs {
log.Printf("MQMainReceive : Received a message: %s", d.Body)
if err = json.Unmarshal(d.Body, &m); err != nil {
failOnError(err, "MQMainReceive : Can't unmarshal")
logOnError(err, "MQMainReceive : Can't unmarshal")
} else {
putMsg(m)
}
putMsg(m)
}
}()
<-forever

View File

@ -9,3 +9,9 @@ func failOnError(err error, msg string) {
log.Fatalf("%s: %s", msg, err)
}
}
func logOnError(err error, msg string) {
if err != nil {
log.Printf("%s: %s", msg, err)
}
}