RabbitMQ Tutorial - Publisher and Consumer program with example in nodeJS

preview_player
Показать описание
In this part of the tutorial we'll write two small programs in nodejs; a producer that sends a single message, and a consumer that receives messages and prints them out. Concentrating on this very simple thing just to get started. It's a "This is technical babaji" of messaging.

How to install RabbitMQ
RABBITMQ UNDERSTANDING MESSAGE BROKER

RabbitMQ is a message broker: it accepts and forwards messages. You can think about it as a post office: when you put the mail that you want posting in a post box, you can be sure that Mr. or Ms. Mailperson will eventually deliver the mail to your recipient. In this analogy, RabbitMQ is a post box, a post office and a postman.

The major difference between RabbitMQ and the post office is that it doesn't deal with paper, instead it accepts, stores and forwards binary blobs of data ‒ messages.

Producing means nothing more than sending. A program that sends messages is a producer

A queue is the name for a post box which lives inside RabbitMQ. Although messages flow through RabbitMQ and your applications, they can only be stored inside a queue. A queue is only bound by the host's memory & disk limits, it's essentially a large message buffer. Many producers can send messages that go to one queue, and many consumers can try to receive data from one queue. This is how we represent a queue

Consuming has a similar meaning to receiving. A consumer is a program that mostly waits to receive messages

Note: that the producer, consumer, and broker do not have to reside on the same host; indeed in most applications they don't. An application can be both a producer and consumer, too.
Рекомендации по теме
Комментарии
Автор

Thank you SO MUCH for this! Always had a problem understanding how consuming works when I publish from a PHP file. This tutorial is perfect and simple to understand :)

MegasXLR
Автор

Helped me today. Thanks for creating this.

suresh
Автор

What does this error mean?

throw error;
^

Error: connect ECONNREFUSED 127.0.0.1:5672
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 5672
}

codeaperture
Автор

Thank You so much for runnning this code as simple as that

tarunnaik
Автор

Thanks bro. Awsome content you created

avtarsashia
Автор

Don't we need to close connection on consumer side?

rudrapratapsingh
Автор

I was wondering how to implement the same in nestjs, can you help😅

arvindkiriti
Автор

Can you tell me how to send messages dynamically?

sourabhrathor
Автор

AMQP microservices pattern using NestJs is effective approach.

ygjyfyz
Автор

How about connection using mqtt to RabbitMQ? I enabled the mqtt plugin and port 1883 but I can't make it work

elyu_vibes
Автор

how can we create an array of received messages via consumer and then use in another js file

prateshtamhankar
Автор

what is diff between socket and RabbitMQ ?

prabu
Автор

How do I implement promise based consumer?

SaitejaPamulapati
Автор

can you tell me what is difference between Synchronous and Asynchronous?

KrishnaManohar
Автор

Thumbs up for the video. But You didnt showed the use of RabbitMQ management application which you have installed in prev video.

easy-stuffs
visit shbcf.ru