Skip to content

Instantly share code, notes, and snippets.

@jasonjohnson
Created April 3, 2014 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonjohnson/9963567 to your computer and use it in GitHub Desktop.
Save jasonjohnson/9963567 to your computer and use it in GitHub Desktop.
Golang AMQP
package main
import (
"fmt"
"github.com/streadway/amqp"
"log"
)
func main() {
connection, err := amqp.Dial("amqp://guest:guest@127.0.0.1:5672")
if err != nil {
panic("Could not connect to broker.")
}
defer connection.Close()
channel, err := connection.Channel()
if err != nil {
panic("Could not open channel.")
}
defer channel.Close()
for i := 0; i < 1000000; i++ {
message := amqp.Publishing{
Body: []byte("Testing 1 2 3..."),
}
err = channel.Publish("publisher", "", false, false, message)
if err != nil {
panic("Could not publish message.")
}
}
fmt.Println("Done!")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment