GithubHelp home page GithubHelp logo

go-rabbitmq's Introduction

go-rabbitmq

step.1 - run container

  • create a new network so all instances can talk to each other
make rabbit-network
  • spin rabbitmq docker container
make rabbit-instance
  • if we explored the container
➜ go-rabbitmq git:(main) docker container ps
CONTAINER ID   IMAGE                  COMMAND                  CREATED          STATUS          PORTS                                                 NAMES
abbfe94ed74a   rabbitmq               "docker-entrypoint.s…"   18 minutes ago   Up 17 minutes   4369/tcp, 5671-5672/tcp, 15691-15692/tcp, 25672/tcp   rabbit-1

notice that :

  • if we run inside a cluster, the port is the 4369/tcp
  • if we have another application needs to communicate to the queue and consume it, the port is 5671-5672/tcp

step.2 - enable management ui

  • open bash inside the container by running
make rabbit-bash
  • then run this command via the rabbitmq-plugin cli
rabbitmq-plugins enable rabbitmq_management
  • make a http request on the browser to localhost:15672
  • the port that I am pointing to is the port that we will use for the application that publishs msgs to the queue ports

Theory

  • Channel is a vritual connection to a specific queue

Authentication between cluster nodes

once the container is running, execute the following

docker exec -it $(host_name) cat /var/lib/rabbitmq/.erlang.cookie

and this will print the cookie for you so we can use it in our rabbitmq instances to talk to each others

  • in order to form a cluster, we have to reset the node before joining the cluster
  • so i will join all the nodes in node-1's cluster using the following commands
    # stop_app will stop the process but keep container running 
	docker exec -it rabbit-node-2 rabbitmqctl stop_app
    # reset all data
	docker exec -it rabbit-node-2 rabbitmqctl reset
    # join the node1 cluster
	docker exec -it rabbit-node-2 rabbitmqctl join_cluster rabbit@rabbit-1
    # start the process again 
	docker exec -it rabbit-node-2 rabbitmqctl start_app
    # print new cluster info 
	docker exec -it rabbit-node-2 rabbitmqctl cluster_status

go-rabbitmq's People

Contributors

fadygamilm avatar

Watchers

 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.