Understanding RabbitMQ®

Image for post
Image for post

What is RabbitMQ®?

How does RabbitMQ® work?

Protocols and connections in RabbitMQ

Sending messages

amqp.connect(‘amqp://localhost’, function(err, connection) {
if (err) {
throw err;
}
connection.createChannel(function(err1, channel) {});
});
amqp.connect(‘amqp://localhost’, function(err, connection) {if (err) {throw err;}connection.createChannel(function(err1, channel) {if (err1) {throw err1;}var queue = ‘logThis’;var msg = ‘This is the message to be logged’;channel.assertQueue(queue, {durable: false});channel.sendToQueue(queue, Buffer.from(msg));console.log(“ [x] Sent %s”, msg);});});
setTimeout(function() {
connection.close();
process.exit(0)
}, 500);

Receiving of messages

amqp.connect(‘amqp://localhost’, function(err, connection) {if (err) {throw err;}connection.createChannel(function(err1, channel) {if (err1) {throw err1;}var queue = ‘logThis’;channel.assertQueue(queue, {durable: false});});});
console.log(“ [*] Waiting for messages in %s. To exit press CTRL+C”, queue);channel.consume(queue, function(msg) {console.log(“ [x] Received %s”, msg.content.toString());}, {noAck: true});

Conclusion

The DLT Labs company logo
The DLT Labs company logo

Written by

DLT Labs is a global leader in Distributed Ledger Technology and Enterprise Products. To know more, head over to: https://www.dltlabs.com/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store