diff --git a/sylvilagus/go/src/meatballhat.com/sylvilagus-chapter02-hello-world-consumer/main.go b/sylvilagus/go/src/meatballhat.com/sylvilagus-chapter02-hello-world-consumer/main.go index 4282227..315c197 100644 --- a/sylvilagus/go/src/meatballhat.com/sylvilagus-chapter02-hello-world-consumer/main.go +++ b/sylvilagus/go/src/meatballhat.com/sylvilagus-chapter02-hello-world-consumer/main.go @@ -26,7 +26,7 @@ func main() { log.Fatal("Failed to declare exchange!: ", err) } - _, err = channel.QueueDeclare("hello-queue", true, false, false, false, nil) + _, err = channel.QueueDeclare("hello-queue", false, false, false, false, nil) if err != nil { log.Fatal("Failed to declare queue!: ", err) } @@ -43,12 +43,17 @@ func main() { quit := make(chan bool) - go func() { + go func(quit chan bool) { + log.Println("Consuming...") for hello := range hellos { - log.Println("hello ->", hello) + log.Printf("hello -> %v\n", string(hello.Body)) hello.Ack(false) + if string(hello.Body) == "quit" { + quit <- true + return + } } - }() + }(quit) <-quit }