A golang application where tasks are published to a queue(rabbitmq) & they are consumed by worker(s)
addreturns the sum of the two arguments provideddivreturns the quotient of the two arguments providedsubreturns the difference of the two arguments providedmulreturns the product of the two arguments provided
Go to the terminal &
-
docker-compose up -dStarting & running the docker containers required -
./publish add 12 5publishing the add task with arguments 12 & 5 -
./consumestarts the worker making it ready to consume tasks from the queue
Its better to run the publish & consume shell scripts from two separate
terminal windows/tabs to get a better view.
I have used the machinery package for asynchronous task queue/job queue based on distributed message passing.
Get it by go get github.com/RichardKnop/machinery/v1.
- Docker / Docker compose
or if you want to run everything locally
Rabbitmqas the brokerRedisas the backend result storage