Skip to content

A simple Go package for interacting with RabbitMQ message broker.

License

Notifications You must be signed in to change notification settings

JagTheFriend/RabbitMQ

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go RabbitMQ

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

System Design

Rough System Design

Installation

Using Docker Compose:

docker compose up

Using Go Modules:

git clone https://github.com/JagTheFriend/RabbitMQ.git
cd ./RabbitMQ/common
go get

Usage

Connecting to RabbitMQ

To 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)

Publishing Messages to a Queue

cd ./RabbitMQ/orders
go run main.go

Consuming Messages from a Queue

cd ./RabbitMQ/payments
go run main.go

About

A simple Go package for interacting with RabbitMQ message broker.

Topics

Resources

License

Stars

Watchers

Forks

Languages