-
-
Save monkrus/283b457a6a5c246b2fe49962632a0b1b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "github.com/streadway/amqp" | |
| ) | |
| func main() { | |
| fmt.Println("Consumer Application") | |
| conn, err := amqp.Dial("amqp://guest:guest@localhost:5672/") | |
| if err != nil { | |
| fmt.Println(err) | |
| panic(err) | |
| } | |
| defer conn.Close() | |
| ch, err := conn.Channel() | |
| if err != nil { | |
| fmt.Println(err) | |
| panic(err) | |
| } | |
| defer ch.Close() | |
| msgs, err := ch.Consume( | |
| "TestQueue", | |
| "", | |
| true, | |
| false, | |
| false, | |
| false, | |
| nil, | |
| ) | |
| forever := make(chan bool) | |
| go func() { | |
| for d := range msgs { | |
| fmt.Printf("Received Message %s\n", d.Body) | |
| } | |
| }() | |
| fmt.Println("Succesfully connected to our RabbitMQ instance") | |
| fmt.Println(" [*] - waiting for messages") | |
| <-forever | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment