Rabbit Message Queue
Installing on Homebrew
Step 1
Step 2
Step 3
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
參考文章
install