Skip to content

Instantly share code, notes, and snippets.

@cawa87
Created June 26, 2020 17:47
Show Gist options
  • Save cawa87/1938b3571869ecb95f3c2d93d7ff0893 to your computer and use it in GitHub Desktop.
Save cawa87/1938b3571869ecb95f3c2d93d7ff0893 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"github.com/streadway/amqp"
)
func main() {
fmt.Println(".")
conn, err := amqp.Dial("amqps://jEET11HDo04kR0bEFe:jEET11HDo04kR0bEFe@stgmq.betradar.com/%2Funifiedfeed%2F31285")
if err != nil {
fmt.Println(err)
panic(err)
}
chnl, err := conn.Channel()
if err != nil {
fmt.Println(err)
panic(err)
}
qee, err := chnl.QueueDeclare(
"", // name, leave empty to generate a unique name
false, // durable
true, // delete when unused
true, // exclusive
false, // noWait
nil, // arguments
)
if err != nil {
fmt.Println(err)
panic(err)
}
err = chnl.QueueBind(
qee.Name, // name of the queue
"#", // bindingKey
"unifiedfeed", // sourceExchange
false, // noWait
nil, // arguments
)
consumerTag := ""
msgs, err := chnl.Consume(
qee.Name, // queue
consumerTag, // consumerTag
true, // auto-ack
true, // exclusive
false, // no-local
false, // no-wait
nil, // args
)
if err != nil {
fmt.Println(err)
panic(err)
}
forver := make(chan bool)
go func(){
for d := range msgs{
fmt.Println(string(d.Body))
}
}()
defer chnl.Close()
defer conn.Close()
<-forver
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment