This is an example of implementation of RabbitMQ in Golang.
Make sure you have installed all of the following prerequisites on your development machine:
This project requires Go v1.20+ to run.
# Clone this project
$ git clone https://github.com/arvians-id/go-rabbitmq.git
# Move to project directory
$ cd go-rabbitmq
# Copy .env.example to .env
$ cp services/category/.env.example services/category/.env \
&& cp services/todo/.env.example services/todo/.env \
&& cp services/user/.env.example services/user/.env \
&& cp services/worker/.env.example services/worker/.env \
&& cp services/category_todo/.env.example services/category_todo/.env \
&& cp gateway/.env.example gateway/.env
# Move to each directory and install the dependencies
$ go mod download
# or
$ go mod tidy
# Migrate tables
$ make migrate table=go_rabbitmq verbose=up
$ make migrate table=go_rabbitmq_test verbose=up
# After installing protocol buffers, generate the proto file
$ make pb# Run all containers
$ docker-compose -f docker-compose.dev.yml up -d
# Run all services
# Warning: Make sure you have running all services in different terminal
$ go run cmd/category/main.go
$ go run cmd/todo/main.go
$ go run cmd/user/main.go
$ go run cmd/worker/main.go
$ go run cmd/category_todo/main.go
$ go run cmd/gateway/main.go
# or you can run all services in different terminal with air
$ air
# graphql playground, open in browser
http://localhost:3000/playground
# rest api, open in postman or curl
$ curl -X GET http://localhost:3000/api/users
# Run test
# Warning: Make sure you have run on development mode
$ make test# Build all services
$ make build
# Run database on docker
$ docker-compose up -d