You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
864 B

package main
import (
"log"
)
import (
"github.com/meatballhat/box-o-sand/sylvilagus/go/sylvilagus"
"github.com/streadway/amqp"
)
func main() {
connection, err := amqp.Dial(sylvilagus.AMQP_URI)
if err != nil {
log.Fatal("Failed to connect!: ", err)
}
defer connection.Close()
channel, err := sylvilagus.CreateHelloTopology(connection)
if err != nil {
log.Fatal("Failed to build topology!: ", 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(quit chan bool) {
log.Println("Consuming...")
for hello := range hellos {
log.Printf("hello -> %v\n", string(hello.Body))
hello.Ack(false)
if string(hello.Body) == "quit" {
quit <- true
return
}
}
}(quit)
<-quit
}