Rabbitmq wrapper library in Go.
Protocols supported: AMQP
Assuming you have go installed(I love GVM), the commands to init module and add this package's dependency are as follows
go mod init <<module name>>
go get -u github.com/adorigi/rabbitmq
Make these two environment variables accessible to your go executable.
RABBIT_USERNAME="<<username for rabbitmq cluster access>"
RABBIT_PASSWORD="<<password for rabbitmq cluster access>>"
RABBIT_URL="<<endpoint for rabbitmq cluster>>"
RABBIT_AMQP_PROTOCOL="<<port>>"
package main
import (
"context"
"time"
"github.com/adorigi/rabbitmq"
)
func main() {
rabbit := rabbitmq.NewRabbit()
rabbit.Configure()
rabbit.ConnectSocket()
rabbit.ConnectChannel()
rabbit.DeclareQueue(<<queuename>>)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
body := "Hello World!"
rabbit.PublishCTXByte(ctx, []byte(body))
rabbit.Close()
}