Giter Club home page Giter Club logo

go-rabbitmq-pubsub's Introduction

RabbitMQ Pub/Sub Producer Consumer

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.

Setup

Clone the repo:

git clone https://github.com/rmeharg/go-rabbitmq-pubsub
cd go-rabbitmq-pubsub

Creating a RabbitMQ queue

Install RabbitMQ via Helm

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
Helm

RabbitMQ Helm Chart version 7.0.0 or later

helm install rabbitmq --set auth.username=user --set auth.password=PASSWORD bitnami/rabbitmq

Wait for RabbitMQ to deploy

⚠️ Be sure to wait until the deployment has completed before continuing. ⚠️

kubectl get po

NAME         READY   STATUS    RESTARTS   AGE
rabbitmq-0   1/1     Running   0          3m3s

Deploying a RabbitMQ consumer

Deploy a consumer

kubectl apply -f deploy/deploy-consumer.yaml

Validate the consumer has deployed

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.

Publishing messages to the queue

Deploy the publisher job

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

Cleanup resources

kubectl delete job rabbitmq-publish
kubectl delete deploy rabbitmq-consumer
helm delete rabbitmq

go-rabbitmq-pubsub's People

Contributors

rmeharg avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.