It's a basic repository which provides how you can publish and subscribe a message using RabbitMQ and Docker.
- Use single instance of RabbitMQ connection.
- Use work queues to distribute tasks among workers.
- Set consumer
prefetchCount
as1
to make RabbitMQ doesn't send a message to busy consumer instead of free one. - Set
autoAck
asfalse
and send a proper acknowledgment from the worker to be able to reconsume a message in case of any exception. - Set
durable
of the queues astrue
to not lose the queue. - Set
persistent
of the messages astrue
to not lose the message. - Use
restart_policy
for the receiver indocker-compose.yml
so that the receiver can try restart until the RabbitMQ is started.
docker-compose up
docker-compose stop
docker-compose rm
docker swarm init
docker stack deploy --compose-file docker-compose.yml queuestack
- If you have some problem with updating service you can use
--with-registry-auth
to solve the problem. Click here for more info.
docker stack rm queuestack
docker stack services queuestack
docker ps -s