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.

47 lines
892 B

package main
import (
"log"
"os"
"time"
)
import (
"github.com/meatballhat/box-o-sand/sylvilagus/go/sylvilagus"
"github.com/streadway/amqp"
)
func main() {
if len(os.Args) < 2 {
log.Fatal("You must provide a message as first arg!")
}
msgBody := string(os.Args[1])
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)
}
msg := amqp.Publishing{
DeliveryMode: amqp.Persistent,
Timestamp: time.Now(),
ContentType: "text/plain",
Body: []byte(msgBody),
}
err = channel.Publish("hello-exchange", "hola", false, false, msg)
if err != nil {
log.Fatal("Failed to publish message!: ", err)
} else {
log.Printf("Published '%v'\n", msgBody)
}
}