Read from Message Queue System and Store into Database
source code
git clone https://github.com/christiangda/mq-to-db.git
cd mq-to-db/
go run -race ./cmd/mq-to-db/main.go --help
# and then
go run -race ./cmd/mq-to-db/main.go --configFile config-sample.yaml
NOTE: the parameter -race
is to check race conditions because we are using Go Concurrency
binary
./mq-to-db --help
RabbitMQ
docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3-management
NOTE:
- RabbitMQ web console: https://localhost:15672
- Username: guest
- Password: guest
PostgreSQL
docker run --rm --name postgresql -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 -d postgres
# logs
docker logs postgresql -f
# remember to stop and remove (--rm in docker run do it for you)
docker stop postgresql
mq-to-db
go run -race ./cmd/mq-to-db/main.go --configFile config-sample.yaml
o
make
./mq-to-db --configFile config-sample.yaml
go build \
-o mq-to-db \
-ldflags "-X github.com/christiangda/mq-to-db/internal/version.Version=$(git rev-parse --abbrev-ref HEAD) -X github.com/christiangda/mq-to-db/internal/version.Revision=$(git rev-parse HEAD) -X github.com/christiangda/mq-to-db/internal/version.Branch=$(git rev-parse --abbrev-ref HEAD) -X github.com/christiangda/mq-to-db/internal/version.BuildUser=\"$(git config --get user.name | tr -d '\040\011\012\015\n')\" -X github.com/christiangda/mq-to-db/internal/version.BuildDate=$(date +'%Y-%m-%dT%H:%M:%S')" \
./cmd/mq-to-db/main.go
- https://golang.org/pkg/database/sql/
- https://golang.org/s/sqldrivers
- https://astaxie.gitbooks.io/build-web-application-with-golang/content/en/05.4.html
- https://gist.github.com/divan/eb11ddc97aab765fb9b093864410fd25
- https://www.alexedwards.net/blog/interfaces-explained
- https://golang.org/doc/effective_go.html#interfaces_and_types
- https://github.com/go-yaml/yaml
- https://www.sohamkamani.com/golang/2018-07-19-golang-omitempty/
- https://ubuntu.com/blog/api-v3-of-the-yaml-package-for-go-is-available
- https://www.rabbitmq.com/queues.html#optional-arguments
- https://www.rabbitmq.com/dlx.html
- https://www.rabbitmq.com/vhosts.html
- https://www.rabbitmq.com/tutorials/tutorial-one-go.html
- https://www.inanzzz.com/index.php/post/0aeg/creating-a-rabbitmq-producer-example-with-golang
### Metrics
### Test