46 lines
864 B
Go
46 lines
864 B
Go
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
|
|
}
|