A simple Go package for interacting with RabbitMQ message broker.
Currently, the package supports the following:
- Connecting to RabbitMQ
- Publishing messages to a queue
- Consuming messages from a queue
Using Docker Compose:
docker compose upUsing Go Modules:
git clone https://github.com/JagTheFriend/RabbitMQ.git
cd ./RabbitMQ/common
go getTo connect to RabbitMQ, you can use the ConnectRabbitAMQP function from the common package. This function takes in the following parameters:
user: The username to use for authentication.pass: The password to use for authentication.host: The hostname or IP address of the RabbitMQ server.port: The port number of the RabbitMQ server.
For simplicity, you can use the following constants:
const (
amqpUser = "guest"
amqpPassword = "guest"
amqpHost = "localhost"
amqpPort = "5672"
)(amqpUser, amqpPassword, amqpHost, amqpPort maybe changed to suit your needs)
cd ./RabbitMQ/orders
go run main.gocd ./RabbitMQ/payments
go run main.go