RabbitMQ-Install

Rabbit Message Queue

Installing on Homebrew

Step 1

1
$ brew update

Step 2

1
$ brew install rabbitmq

Step 3

1
$ rabbitmqctl status

Example

Client

send.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
const amqp = require('amqplib/callback_api');

amqp.connect('amqp://localhost', function (err, conn) {
conn.createChannel((err, ch) => {
const q = 'hello';
const msg = 'Hello World!';

ch.assertQueue(q, { durable: false });
ch.sendToQueue(q, new Buffer('Hello world'));
console.log(" [x] Sent 'Hello World!'");

});
setTimeout(function () { conn.close(); process.exit(0) }, 500);
});

Server

receive.js

1
2
3
4
5
6
7
8
9
10
11
12
13
const amqp = require('amqplib/callback_api');

amqp.connect('amqp://localhost', function (err, conn) {
conn.createChannel((err, ch) => {
const q = 'hello';
const msg = 'Hello World!';

ch.assertQueue(q, { durable: false });
ch.sendToQueue(q, new Buffer('Hello world'));

});
setTimeout(function () { conn.close(); process.exit(0) }, 500);
});

Result

Demo Result

參考文章

install

文章目录
  1. 1. Rabbit Message Queue
    1. 1.1. Installing on Homebrew
      1. 1.1.1. Step 1
      2. 1.1.2. Step 2
      3. 1.1.3. Step 3
    2. 1.2. Example
      1. 1.2.1. Client
      2. 1.2.2. Server
      3. 1.2.3. Result
    3. 1.3. 參考文章
|