From f1c4f2005868b0445c8cd1aede1204bf9e68c28d Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Wed, 14 Nov 2012 22:27:46 -0500 Subject: [PATCH] Almost kinda there... --- .../main.go | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) 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 eb58ecf..4282227 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,8 +26,29 @@ func main() { log.Fatal("Failed to declare exchange!: ", err) } + _, err = channel.QueueDeclare("hello-queue", true, false, false, false, nil) + if err != nil { + log.Fatal("Failed to declare queue!: ", err) + } + err = channel.QueueBind("hello-queue", "hola", "hello-exchange", false, nil) if err != nil { log.Fatal("Failed to bind to queue!: ", err) } + + hellos, err := channel.Consume("hello-queue", "hello-consumer", false, false, false, false, nil) + if err != nil { + log.Fatal("Failed to start consuming!:", err) + } + + quit := make(chan bool) + + go func() { + for hello := range hellos { + log.Println("hello ->", hello) + hello.Ack(false) + } + }() + + <-quit }