Skip to content

Latest commit

 

History

History
78 lines (49 loc) · 1.83 KB

README.md

File metadata and controls

78 lines (49 loc) · 1.83 KB

RABBITMQ - SYSTEM MENSSAGING

Example of using messages to communicate between systems based on microservices using queues.

Prerequisites

  • Docker Compose version (1.25.4)
  • Docker version (19.03.8)
  • Node version (12.16.1)
  • Npm version (6.14.4)

Getting Started

  1. Fork this repository and clone on your machine
  2. Change the directory to rabbitmq-nodejs-messaging-example where you cloned it;
  3. At the terminal, run:
/* Install dependencies from consumer */

$ cd consumer

$ npm install

/* Install dependencies from producer */

$ cd producer

$ npm install
  1. Run docker. In the directory rabbitmq-nodejs-messaging-example execute.
/* Up docker */

$ docker-compose up -d

/* Down docker */

$ docker-compose down
  1. Open robbitMQ: the host localhost:15672 and start using it. Credentials user: rabbitmq password: rabbitmq

  2. Execute project on consumer & producer.

/* execute on directory consumer */

$ npm run start

/* execute on directory producer */

$ npm run start

How it works ?

  • Producer

    • The guy who will send the message, data.
  • Exchange

    • Responsible for receiving these messages, and deciding which queue this message will be sent to. Remembering when you work with applications, you don't work with just one queue, you can have queues of everything that is different and types, and several exchanges.
  • Queue

    • The queue stores messages and dispatches them.
  • Consumer

    • The consumer has a process that listens to everything that arrives in the queue. In this case, he removes the messages from the queue, and gives a ACK: acknowledge.