- Docker Compose version (1.25.4)
- Docker version (19.03.8)
- Node version (12.16.1)
- Npm version (6.14.4)
- Fork this repository and clone on your machine
- Change the directory to
rabbitmq-nodejs-messaging-example
where you cloned it; - At the terminal, run:
/* Install dependencies from consumer */
$ cd consumer
$ npm install
/* Install dependencies from producer */
$ cd producer
$ npm install
- Run docker. In the directory
rabbitmq-nodejs-messaging-example
execute.
/* Up docker */
$ docker-compose up -d
/* Down docker */
$ docker-compose down
-
Open robbitMQ: the host localhost:15672 and start using it. Credentials
user: rabbitmq password: rabbitmq
-
Execute project on consumer & producer.
/* execute on directory consumer */
$ npm run start
/* execute on directory producer */
$ npm run start
-
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
.
- 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