A simple docker container that will receive messages from a RabbitMQ queue. The reciever will receive a single message at a time (per instance), and sleep for 1 second to simulate performing work.
Clone the repo:
git clone https://github.com/rmeharg/go-rabbitmq-pubsub
cd go-rabbitmq-pubsub
Since the Helm stable repositoty was migrated to the Bitnami repository (https://github.com/helm/charts/tree/master/stable/rabbitmq), add the Bitnami repo and use it during the installation (bitnami/ instead of stable/)
$ helm repo add bitnami https://charts.bitnami.com/bitnami
RabbitMQ Helm Chart version 7.0.0 or later
helm install rabbitmq --set auth.username=user --set auth.password=PASSWORD bitnami/rabbitmq
kubectl get po
NAME READY STATUS RESTARTS AGE
rabbitmq-0 1/1 Running 0 3m3s
kubectl apply -f deploy/deploy-consumer.yaml
kubectl get deploy
You should see rabbitmq-consumer
deployment with 0 pods as there currently aren't any queue messages. It is scale to zero.
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
rabbitmq-consumer 0 0 0 0 3s
This consumer is set to consume one message per instance, sleep for 1 second, and then acknowledge completion of the message. This is used to simulate work.
The following job will publish 300 messages to the "hello" queue the deployment is listening to. You can modify the exact number of published messages in the deploy-publisher-job.yaml
file.
kubectl apply -f deploy/deploy-publisher-job.yaml
kubectl delete job rabbitmq-publish
kubectl delete deploy rabbitmq-consumer
helm delete rabbitmq