Skip to content

Latest commit

 

History

History
163 lines (104 loc) · 6.04 KB

README.md

File metadata and controls

163 lines (104 loc) · 6.04 KB

mq-to-db

Read from Message Queue System and Store into Database

Characteristics

  • The process (job) of consume one message from queue and store into the database is synchronous because every message needs to be acknowledge (confirm as storage).

How to execute

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 -raceis 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:

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

How to build

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

Internal References

External References

Free books

Blogs

Databases

Project Layout

Interfaces

Context

YAML|JSON to Struct

Config Files, Flags, Env Vars

RabbitMQ

Logs

### Metrics

### Test

Variable Injection

Iterators

Concurrency

Workers Pool