Update worker.go

fix: Ack should be an the end of loop.
This commit is contained in:
Larry Qu 2017-04-10 22:41:44 +08:00 committed by GitHub
parent 083b214459
commit 92bcb23944

View File

@ -56,11 +56,11 @@ func main() {
go func() { go func() {
for d := range msgs { for d := range msgs {
log.Printf("Received a message: %s", d.Body) log.Printf("Received a message: %s", d.Body)
d.Ack(false)
dot_count := bytes.Count(d.Body, []byte(".")) dot_count := bytes.Count(d.Body, []byte("."))
t := time.Duration(dot_count) t := time.Duration(dot_count)
time.Sleep(t * time.Second) time.Sleep(t * time.Second)
log.Printf("Done") log.Printf("Done")
d.Ack(false)
} }
}() }()