-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathsend.js
31 lines (31 loc) · 996 Bytes
/
send.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
'use strict';
const bramqp = require('bramqp');
const net = require('net');
const async = require('async');
const socket = net.connect({
port: 5672
});
bramqp.initialize(socket, 'rabbitmq/full/amqp0-9-1.stripped.extended', function(error, handle) {
async.series([function(seriesCallback) {
handle.openAMQPCommunication('guest', 'guest', true, seriesCallback);
}, function(seriesCallback) {
handle.queue.declare(1, 'hello');
handle.once('1:queue.declare-ok', function(channel, method, data) {
console.log('queue declared');
seriesCallback();
});
}, function(seriesCallback) {
handle.basic.publish(1, '', 'hello', false, false, function() {
handle.content(1, 'basic', {}, 'Hello World!', seriesCallback);
});
}, function(seriesCallback) {
setTimeout(function() {
handle.closeAMQPCommunication(seriesCallback);
}, 10 * 1000);
}, function(seriesCallback) {
handle.socket.end();
setImmediate(seriesCallback);
}], function() {
console.log('all done');
});
});