From 46933f061152ba33faf61d7b6feec0753e317c62 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Wed, 14 Nov 2012 23:47:08 -0500 Subject: [PATCH] Much better like that, yap --- .../main.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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 }