typespeed 2.0.13 → 2.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.decorator.js +0 -1
- package/dist/database.decorator.js +0 -1
- package/dist/default/express-server.class.js +0 -1
- package/dist/default/log-default.class.js +0 -1
- package/dist/default/node-cache.class.js +0 -1
- package/dist/default/rabbitmq.class.js +0 -1
- package/dist/default/read-write-db.class.js +0 -1
- package/dist/default/redis.class.js +0 -1
- package/dist/factory/cache-factory.class.js +0 -1
- package/dist/factory/data-source-factory.class.js +0 -1
- package/dist/factory/log-factory.class.js +0 -1
- package/dist/factory/server-factory.class.js +0 -1
- package/dist/route.decorator.js +0 -1
- package/dist/scaffold/command.js +0 -1
- package/dist/typespeed.d.ts +133 -12
- package/dist/typespeed.js +1 -1
- package/package.json +2 -2
- package/src/typespeed.d.ts +133 -0
- package/src/typespeed.ts +2 -1
- package/test/node_modules/.package-lock.json +112 -4
- package/test/node_modules/@acuminous/bitsyntax/.github/workflows/node-js-ci.yml +17 -0
- package/test/node_modules/@acuminous/bitsyntax/.github/workflows/node-js-publish.yml +30 -0
- package/test/node_modules/@acuminous/bitsyntax/LICENSE +6 -0
- package/test/node_modules/@acuminous/bitsyntax/LICENSE-MIT +21 -0
- package/test/node_modules/@acuminous/bitsyntax/Makefile +15 -0
- package/test/node_modules/@acuminous/bitsyntax/README.md +308 -0
- package/test/node_modules/@acuminous/bitsyntax/index.js +10 -0
- package/test/node_modules/@acuminous/bitsyntax/lib/compile.js +303 -0
- package/test/node_modules/@acuminous/bitsyntax/lib/constructor.js +142 -0
- package/test/node_modules/@acuminous/bitsyntax/lib/grammar.pegjs +67 -0
- package/test/node_modules/@acuminous/bitsyntax/lib/interp.js +232 -0
- package/test/node_modules/@acuminous/bitsyntax/lib/parse.js +32 -0
- package/test/node_modules/@acuminous/bitsyntax/lib/parser.js +1173 -0
- package/test/node_modules/@acuminous/bitsyntax/lib/pattern.js +119 -0
- package/test/node_modules/@acuminous/bitsyntax/package.json +36 -0
- package/test/node_modules/@acuminous/bitsyntax/test/consing.test.js +50 -0
- package/test/node_modules/@acuminous/bitsyntax/test/matching.test.js +193 -0
- package/test/node_modules/@types/node/README.md +1 -1
- package/test/node_modules/@types/node/buffer.d.ts +5 -2
- package/test/node_modules/@types/node/child_process.d.ts +27 -0
- package/test/node_modules/@types/node/globals.d.ts +1 -0
- package/test/node_modules/@types/node/package.json +2 -2
- package/test/node_modules/@types/node/test.d.ts +43 -20
- package/test/node_modules/@types/node/ts4.8/buffer.d.ts +5 -2
- package/test/node_modules/@types/node/ts4.8/child_process.d.ts +27 -0
- package/test/node_modules/@types/node/ts4.8/globals.d.ts +1 -0
- package/test/node_modules/@types/node/ts4.8/test.d.ts +43 -19
- package/test/node_modules/@types/node/ts4.8/url.d.ts +3 -3
- package/test/node_modules/@types/node/ts4.8/util.d.ts +1 -1
- package/test/node_modules/@types/node/url.d.ts +3 -3
- package/test/node_modules/@types/node/util.d.ts +1 -1
- package/test/node_modules/amqplib/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- package/test/node_modules/amqplib/.github/workflows/test.yml +38 -0
- package/test/node_modules/amqplib/CHANGELOG.md +430 -0
- package/test/node_modules/amqplib/LICENSE +6 -0
- package/test/node_modules/amqplib/LICENSE-MIT +21 -0
- package/test/node_modules/amqplib/Makefile +47 -0
- package/test/node_modules/amqplib/README.md +157 -0
- package/test/node_modules/amqplib/bin/generate-defs.js +722 -0
- package/test/node_modules/amqplib/callback_api.js +22 -0
- package/test/node_modules/amqplib/channel_api.js +16 -0
- package/test/node_modules/amqplib/examples/headers.js +42 -0
- package/test/node_modules/amqplib/examples/receive_generator.js +39 -0
- package/test/node_modules/amqplib/examples/send_generators.js +42 -0
- package/test/node_modules/amqplib/examples/ssl.js +64 -0
- package/test/node_modules/amqplib/examples/tutorials/README.md +93 -0
- package/test/node_modules/amqplib/examples/tutorials/callback_api/emit_log.js +28 -0
- package/test/node_modules/amqplib/examples/tutorials/callback_api/emit_log_direct.js +30 -0
- package/test/node_modules/amqplib/examples/tutorials/callback_api/emit_log_topic.js +27 -0
- package/test/node_modules/amqplib/examples/tutorials/callback_api/new_task.js +27 -0
- package/test/node_modules/amqplib/examples/tutorials/callback_api/receive.js +30 -0
- package/test/node_modules/amqplib/examples/tutorials/callback_api/receive_logs.js +36 -0
- package/test/node_modules/amqplib/examples/tutorials/callback_api/receive_logs_direct.js +56 -0
- package/test/node_modules/amqplib/examples/tutorials/callback_api/receive_logs_topic.js +55 -0
- package/test/node_modules/amqplib/examples/tutorials/callback_api/rpc_client.js +49 -0
- package/test/node_modules/amqplib/examples/tutorials/callback_api/rpc_server.js +45 -0
- package/test/node_modules/amqplib/examples/tutorials/callback_api/send.js +29 -0
- package/test/node_modules/amqplib/examples/tutorials/callback_api/worker.js +35 -0
- package/test/node_modules/amqplib/examples/tutorials/emit_log.js +19 -0
- package/test/node_modules/amqplib/examples/tutorials/emit_log_direct.js +20 -0
- package/test/node_modules/amqplib/examples/tutorials/emit_log_topic.js +19 -0
- package/test/node_modules/amqplib/examples/tutorials/new_task.js +18 -0
- package/test/node_modules/amqplib/examples/tutorials/package.json +16 -0
- package/test/node_modules/amqplib/examples/tutorials/receive.js +21 -0
- package/test/node_modules/amqplib/examples/tutorials/receive_logs.js +28 -0
- package/test/node_modules/amqplib/examples/tutorials/receive_logs_direct.js +44 -0
- package/test/node_modules/amqplib/examples/tutorials/receive_logs_topic.js +43 -0
- package/test/node_modules/amqplib/examples/tutorials/rpc_client.js +52 -0
- package/test/node_modules/amqplib/examples/tutorials/rpc_server.js +39 -0
- package/test/node_modules/amqplib/examples/tutorials/send.js +23 -0
- package/test/node_modules/amqplib/examples/tutorials/worker.js +28 -0
- package/test/node_modules/amqplib/examples/waitForConfirms.js +22 -0
- package/test/node_modules/amqplib/lib/api_args.js +314 -0
- package/test/node_modules/amqplib/lib/bitset.js +130 -0
- package/test/node_modules/amqplib/lib/callback_model.js +327 -0
- package/test/node_modules/amqplib/lib/channel.js +499 -0
- package/test/node_modules/amqplib/lib/channel_model.js +302 -0
- package/test/node_modules/amqplib/lib/codec.js +321 -0
- package/test/node_modules/amqplib/lib/connect.js +189 -0
- package/test/node_modules/amqplib/lib/connection.js +663 -0
- package/test/node_modules/amqplib/lib/credentials.js +42 -0
- package/test/node_modules/amqplib/lib/defs.js +4966 -0
- package/test/node_modules/amqplib/lib/error.js +24 -0
- package/test/node_modules/amqplib/lib/format.js +40 -0
- package/test/node_modules/amqplib/lib/frame.js +113 -0
- package/test/node_modules/amqplib/lib/heartbeat.js +89 -0
- package/test/node_modules/amqplib/lib/mux.js +129 -0
- package/test/node_modules/amqplib/package.json +37 -0
- package/test/node_modules/amqplib/test/bitset.js +69 -0
- package/test/node_modules/amqplib/test/callback_api.js +312 -0
- package/test/node_modules/amqplib/test/channel.js +621 -0
- package/test/node_modules/amqplib/test/channel_api.js +596 -0
- package/test/node_modules/amqplib/test/codec.js +237 -0
- package/test/node_modules/amqplib/test/connect.js +197 -0
- package/test/node_modules/amqplib/test/connection.js +390 -0
- package/test/node_modules/amqplib/test/data.js +254 -0
- package/test/node_modules/amqplib/test/frame.js +198 -0
- package/test/node_modules/amqplib/test/mux.js +204 -0
- package/test/node_modules/amqplib/test/util.js +219 -0
- package/test/node_modules/buffer-more-ints/.travis.yml +6 -0
- package/test/node_modules/buffer-more-ints/LICENSE +19 -0
- package/test/node_modules/buffer-more-ints/README.md +69 -0
- package/test/node_modules/buffer-more-ints/buffer-more-ints-tests.js +183 -0
- package/test/node_modules/buffer-more-ints/buffer-more-ints.js +432 -0
- package/test/node_modules/buffer-more-ints/package.json +19 -0
- package/test/node_modules/buffer-more-ints/polyfill.js +71 -0
- package/test/node_modules/core-util-is/LICENSE +19 -0
- package/test/node_modules/core-util-is/README.md +3 -0
- package/test/node_modules/core-util-is/lib/util.js +107 -0
- package/test/node_modules/core-util-is/package.json +38 -0
- package/test/node_modules/debug/LICENSE +20 -0
- package/test/node_modules/debug/README.md +481 -0
- package/test/node_modules/debug/package.json +59 -0
- package/test/node_modules/debug/src/browser.js +269 -0
- package/test/node_modules/debug/src/common.js +274 -0
- package/test/node_modules/debug/src/index.js +10 -0
- package/test/node_modules/debug/src/node.js +263 -0
- package/test/node_modules/inherits/LICENSE +16 -0
- package/test/node_modules/inherits/README.md +42 -0
- package/test/node_modules/inherits/inherits.js +9 -0
- package/test/node_modules/inherits/inherits_browser.js +27 -0
- package/test/node_modules/inherits/package.json +29 -0
- package/test/node_modules/isarray/README.md +54 -0
- package/test/node_modules/isarray/build/build.js +209 -0
- package/test/node_modules/isarray/component.json +19 -0
- package/test/node_modules/isarray/index.js +3 -0
- package/test/node_modules/isarray/package.json +25 -0
- package/test/node_modules/ms/index.js +162 -0
- package/test/node_modules/ms/license.md +21 -0
- package/test/node_modules/ms/package.json +37 -0
- package/test/node_modules/ms/readme.md +60 -0
- package/test/node_modules/querystringify/LICENSE +22 -0
- package/test/node_modules/querystringify/README.md +61 -0
- package/test/node_modules/querystringify/index.js +118 -0
- package/test/node_modules/querystringify/package.json +38 -0
- package/test/node_modules/readable-stream/LICENSE +18 -0
- package/test/node_modules/readable-stream/README.md +15 -0
- package/test/node_modules/readable-stream/duplex.js +1 -0
- package/test/node_modules/readable-stream/float.patch +923 -0
- package/test/node_modules/readable-stream/lib/_stream_duplex.js +89 -0
- package/test/node_modules/readable-stream/lib/_stream_passthrough.js +46 -0
- package/test/node_modules/readable-stream/lib/_stream_readable.js +951 -0
- package/test/node_modules/readable-stream/lib/_stream_transform.js +209 -0
- package/test/node_modules/readable-stream/lib/_stream_writable.js +477 -0
- package/test/node_modules/readable-stream/package.json +32 -0
- package/test/node_modules/readable-stream/passthrough.js +1 -0
- package/test/node_modules/readable-stream/readable.js +10 -0
- package/test/node_modules/readable-stream/transform.js +1 -0
- package/test/node_modules/readable-stream/writable.js +1 -0
- package/test/node_modules/requires-port/.travis.yml +19 -0
- package/test/node_modules/requires-port/LICENSE +22 -0
- package/test/node_modules/requires-port/README.md +47 -0
- package/test/node_modules/requires-port/index.js +38 -0
- package/test/node_modules/requires-port/package.json +47 -0
- package/test/node_modules/requires-port/test.js +98 -0
- package/test/node_modules/safe-buffer/LICENSE +21 -0
- package/test/node_modules/safe-buffer/README.md +584 -0
- package/test/node_modules/safe-buffer/index.d.ts +187 -0
- package/test/node_modules/safe-buffer/index.js +62 -0
- package/test/node_modules/safe-buffer/package.json +37 -0
- package/test/node_modules/string_decoder/LICENSE +20 -0
- package/test/node_modules/string_decoder/README.md +7 -0
- package/test/node_modules/string_decoder/index.js +221 -0
- package/test/node_modules/string_decoder/package.json +25 -0
- package/test/node_modules/url-parse/LICENSE +22 -0
- package/test/node_modules/url-parse/README.md +153 -0
- package/test/node_modules/url-parse/dist/url-parse.js +755 -0
- package/test/node_modules/url-parse/dist/url-parse.min.js +1 -0
- package/test/node_modules/url-parse/dist/url-parse.min.js.map +1 -0
- package/test/node_modules/url-parse/index.js +589 -0
- package/test/node_modules/url-parse/package.json +49 -0
- package/test/src/test-mq.class.ts +1 -2
- package/tsconfig.json +4 -3
- package/dist/core.decorator.d.ts +0 -18
- package/dist/core.decorator.js.map +0 -1
- package/dist/database.decorator.d.ts +0 -24
- package/dist/database.decorator.js.map +0 -1
- package/dist/default/express-server.class.d.ts +0 -15
- package/dist/default/express-server.class.js.map +0 -1
- package/dist/default/log-default.class.d.ts +0 -6
- package/dist/default/log-default.class.js.map +0 -1
- package/dist/default/node-cache.class.d.ts +0 -13
- package/dist/default/node-cache.class.js.map +0 -1
- package/dist/default/rabbitmq.class.d.ts +0 -9
- package/dist/default/rabbitmq.class.js.map +0 -1
- package/dist/default/read-write-db.class.d.ts +0 -10
- package/dist/default/read-write-db.class.js.map +0 -1
- package/dist/default/redis.class.d.ts +0 -5
- package/dist/default/redis.class.js.map +0 -1
- package/dist/factory/cache-factory.class.d.ts +0 -7
- package/dist/factory/cache-factory.class.js.map +0 -1
- package/dist/factory/data-source-factory.class.d.ts +0 -4
- package/dist/factory/data-source-factory.class.js.map +0 -1
- package/dist/factory/log-factory.class.d.ts +0 -4
- package/dist/factory/log-factory.class.js.map +0 -1
- package/dist/factory/server-factory.class.d.ts +0 -6
- package/dist/factory/server-factory.class.js.map +0 -1
- package/dist/route.decorator.d.ts +0 -8
- package/dist/route.decorator.js.map +0 -1
- package/dist/scaffold/command.d.ts +0 -2
- package/dist/scaffold/command.js.map +0 -1
- package/dist/typespeed.js.map +0 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
var raw_connect = require('./lib/connect').connect;
|
|
2
|
+
var CallbackModel = require('./lib/callback_model').CallbackModel;
|
|
3
|
+
|
|
4
|
+
// Supports three shapes:
|
|
5
|
+
// connect(url, options, callback)
|
|
6
|
+
// connect(url, callback)
|
|
7
|
+
// connect(callback)
|
|
8
|
+
function connect(url, options, cb) {
|
|
9
|
+
if (typeof url === 'function')
|
|
10
|
+
cb = url, url = false, options = false;
|
|
11
|
+
else if (typeof options === 'function')
|
|
12
|
+
cb = options, options = false;
|
|
13
|
+
|
|
14
|
+
raw_connect(url, options, function(err, c) {
|
|
15
|
+
if (err === null) cb(null, new CallbackModel(c));
|
|
16
|
+
else cb(err);
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
module.exports.connect = connect;
|
|
21
|
+
module.exports.credentials = require('./lib/credentials');
|
|
22
|
+
module.exports.IllegalOperationError = require('./lib/error').IllegalOperationError;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var raw_connect = require('./lib/connect').connect;
|
|
2
|
+
var ChannelModel = require('./lib/channel_model').ChannelModel;
|
|
3
|
+
var promisify = require('util').promisify;
|
|
4
|
+
|
|
5
|
+
function connect(url, connOptions) {
|
|
6
|
+
return promisify(function(cb) {
|
|
7
|
+
return raw_connect(url, connOptions, cb);
|
|
8
|
+
})()
|
|
9
|
+
.then(function(conn) {
|
|
10
|
+
return new ChannelModel(conn);
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
module.exports.connect = connect;
|
|
15
|
+
module.exports.credentials = require('./lib/credentials');
|
|
16
|
+
module.exports.IllegalOperationError = require('./lib/error').IllegalOperationError;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// Example of using a headers exchange
|
|
4
|
+
|
|
5
|
+
var amqp = require('../')
|
|
6
|
+
|
|
7
|
+
amqp.connect().then(function(conn) {
|
|
8
|
+
return conn.createChannel().then(withChannel);
|
|
9
|
+
}, console.error);
|
|
10
|
+
|
|
11
|
+
function withChannel(ch) {
|
|
12
|
+
// NB the type of the exchange is 'headers'
|
|
13
|
+
ch.assertExchange('matching exchange', 'headers').then(function(ex) {
|
|
14
|
+
ch.assertQueue().then(function(q) {
|
|
15
|
+
bindAndConsume(ch, ex, q).then(function() {
|
|
16
|
+
send(ch, ex);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function bindAndConsume(ch, ex, q) {
|
|
23
|
+
// When using a headers exchange, the headers to be matched go in
|
|
24
|
+
// the binding arguments. The routing key is ignore, so best left
|
|
25
|
+
// empty.
|
|
26
|
+
|
|
27
|
+
// 'x-match' is 'all' or 'any', meaning "all fields must match" or
|
|
28
|
+
// "at least one field must match", respectively. The values to be
|
|
29
|
+
// matched go in subsequent fields.
|
|
30
|
+
ch.bindQueue(q.queue, ex.exchange, '', {'x-match': 'any',
|
|
31
|
+
'foo': 'bar',
|
|
32
|
+
'baz': 'boo'});
|
|
33
|
+
return ch.consume(q.queue, function(msg) {
|
|
34
|
+
console.log(msg.content.toString());
|
|
35
|
+
}, {noAck: true});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function send(ch, ex) {
|
|
39
|
+
// The headers for a message are given as an option to `publish`:
|
|
40
|
+
ch.publish(ex.exchange, '', Buffer.from('hello'), {headers: {baz: 'boo'}});
|
|
41
|
+
ch.publish(ex.exchange, '', Buffer.from('world'), {headers: {foo: 'bar'}});
|
|
42
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
const co = require('co');
|
|
5
|
+
const amqp = require('amqplib');
|
|
6
|
+
const readline = require('readline');
|
|
7
|
+
|
|
8
|
+
co(function* () {
|
|
9
|
+
const myConsumer = (msg) => {
|
|
10
|
+
if (msg !== null) {
|
|
11
|
+
console.log('consuming message %s in generator', JSON.stringify(msg.content.toString()));
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const conn = yield amqp.connect('amqp://localhost');
|
|
15
|
+
try {
|
|
16
|
+
// create a message to consume
|
|
17
|
+
const q = 'hello';
|
|
18
|
+
const msg = 'Hello World!';
|
|
19
|
+
const channel = yield conn.createChannel();
|
|
20
|
+
yield channel.assertQueue(q);
|
|
21
|
+
channel.sendToQueue(q, Buffer.from(msg));
|
|
22
|
+
console.log(" [x] Sent '%s'", msg);
|
|
23
|
+
// consume the message
|
|
24
|
+
yield channel.consume(q, myConsumer, { noAck: true });
|
|
25
|
+
}
|
|
26
|
+
catch (e) {
|
|
27
|
+
throw e;
|
|
28
|
+
}
|
|
29
|
+
}).catch(err => {
|
|
30
|
+
console.warn('Error:', err);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const rl = readline.createInterface({
|
|
34
|
+
input: process.stdin,
|
|
35
|
+
output: process.stdout
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// pend until message is consumed
|
|
39
|
+
rl.question('newline to exit', () => process.exit());
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
// NB this requires the module 'co':
|
|
6
|
+
// npm install co
|
|
7
|
+
const co = require('co');
|
|
8
|
+
const amqp = require('amqplib');
|
|
9
|
+
|
|
10
|
+
co(function* () {
|
|
11
|
+
// connection errors are handled in the co .catch handler
|
|
12
|
+
const conn = yield amqp.connect('amqp://localhost');
|
|
13
|
+
|
|
14
|
+
// try catch will throw any errors from the yielding the following promises to the co .catch handler
|
|
15
|
+
try {
|
|
16
|
+
const q = 'hello';
|
|
17
|
+
const msg = 'Hello World!';
|
|
18
|
+
|
|
19
|
+
// use a confirm channel so we can check the message is sent OK.
|
|
20
|
+
const channel = yield conn.createConfirmChannel();
|
|
21
|
+
|
|
22
|
+
yield channel.assertQueue(q);
|
|
23
|
+
|
|
24
|
+
channel.sendToQueue(q, Buffer.from(msg));
|
|
25
|
+
|
|
26
|
+
// if message has been nacked, this will result in an error (rejected promise);
|
|
27
|
+
yield channel.waitForConfirms();
|
|
28
|
+
|
|
29
|
+
console.log(" [x] Sent '%s'", msg);
|
|
30
|
+
|
|
31
|
+
channel.close();
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
throw e;
|
|
35
|
+
}
|
|
36
|
+
finally {
|
|
37
|
+
conn.close();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
}).catch(err => {
|
|
41
|
+
console.warn('Error:', err);
|
|
42
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Example of using a TLS/SSL connection. Note that the server must be
|
|
2
|
+
// configured to accept SSL connections; see, for example,
|
|
3
|
+
// http://www.rabbitmq.com/ssl.html.
|
|
4
|
+
//
|
|
5
|
+
// When trying this out, I followed the RabbitMQ SSL guide above,
|
|
6
|
+
// almost verbatim. I set the CN of the server certificate to
|
|
7
|
+
// 'localhost' rather than $(hostname) (since on my MBP hostname ends
|
|
8
|
+
// up being "<blah>.local", which is just weird). My client
|
|
9
|
+
// certificates etc., are in `../etc/client/`. My testca certificate
|
|
10
|
+
// is in `../etc/testca` and server certs etc., in `../etc/server`,
|
|
11
|
+
// and I've made a `rabbitmq.config` file, with which I start
|
|
12
|
+
// RabbitMQ:
|
|
13
|
+
//
|
|
14
|
+
// RABBITMQ_CONFIG_FILE=`pwd`/../etc/server/rabbitmq \
|
|
15
|
+
// /usr/local/sbin/rabbitmq-server &
|
|
16
|
+
//
|
|
17
|
+
// A way to check RabbitMQ's running with SSL OK is to use
|
|
18
|
+
//
|
|
19
|
+
// openssl s_client -connect localhost:5671
|
|
20
|
+
|
|
21
|
+
var amqp = require('../');
|
|
22
|
+
var fs = require('fs');
|
|
23
|
+
|
|
24
|
+
// Assemble the SSL options; for verification we need at least
|
|
25
|
+
// * a certificate to present to the server ('cert', in PEM format)
|
|
26
|
+
// * the private key for the certificate ('key', in PEM format)
|
|
27
|
+
// * (possibly) a passphrase for the private key
|
|
28
|
+
//
|
|
29
|
+
// The first two may be replaced with a PKCS12 file ('pfx', in pkcs12
|
|
30
|
+
// format)
|
|
31
|
+
|
|
32
|
+
// We will also want to list the CA certificates that we will trust,
|
|
33
|
+
// since we're using a self-signed certificate. It is NOT recommended
|
|
34
|
+
// to use `rejectUnauthorized: false`.
|
|
35
|
+
|
|
36
|
+
// Options for full client and server verification:
|
|
37
|
+
var opts = {
|
|
38
|
+
cert: fs.readFileSync('../etc/client/cert.pem'),
|
|
39
|
+
key: fs.readFileSync('../etc/client/key.pem'),
|
|
40
|
+
// cert and key or
|
|
41
|
+
// pfx: fs.readFileSync('../etc/client/keycert.p12'),
|
|
42
|
+
passphrase: 'MySecretPassword',
|
|
43
|
+
ca: [fs.readFileSync('../etc/testca/cacert.pem')]
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// Options for just confidentiality. This requires RabbitMQ's SSL
|
|
47
|
+
// configuration to include the items
|
|
48
|
+
//
|
|
49
|
+
// {verify, verify_none},
|
|
50
|
+
// {fail_if_no_peer_cert,false}
|
|
51
|
+
//
|
|
52
|
+
// var opts = { ca: [fs.readFileSync('../etc/testca/cacert.pem')] };
|
|
53
|
+
|
|
54
|
+
// Option to use the SSL client certificate for authentication
|
|
55
|
+
// opts.credentials = amqp.credentials.external();
|
|
56
|
+
|
|
57
|
+
var open = amqp.connect('amqps://localhost', opts);
|
|
58
|
+
|
|
59
|
+
open.then(function(conn) {
|
|
60
|
+
process.on('SIGINT', conn.close.bind(conn));
|
|
61
|
+
return conn.createChannel().then(function(ch) {
|
|
62
|
+
ch.sendToQueue('foo', Buffer.from('Hello World!'));
|
|
63
|
+
});
|
|
64
|
+
}).then(null, console.warn);
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# RabbitMQ tutorials
|
|
2
|
+
|
|
3
|
+
This directory contains the [RabbitMQ tutorials][rabbitmq-tutes],
|
|
4
|
+
ported to amqplib. The sub-directory `callback_api` has translations
|
|
5
|
+
of the tutorial programs to the callback-oriented API.
|
|
6
|
+
|
|
7
|
+
## Preparation
|
|
8
|
+
|
|
9
|
+
To run the tutorial code, you need amqplib installed. Assuming you are
|
|
10
|
+
in a clone of the amqplib repository, from the tutorials directory:
|
|
11
|
+
|
|
12
|
+
npm install
|
|
13
|
+
|
|
14
|
+
or to use the latest released version,
|
|
15
|
+
|
|
16
|
+
npm install amqplib
|
|
17
|
+
|
|
18
|
+
Then just run each file as a script, e.g., in bash
|
|
19
|
+
|
|
20
|
+
./send.js
|
|
21
|
+
|
|
22
|
+
or
|
|
23
|
+
|
|
24
|
+
node send.js
|
|
25
|
+
|
|
26
|
+
or
|
|
27
|
+
|
|
28
|
+
nave use 0.8 node send.js
|
|
29
|
+
|
|
30
|
+
## [Tutorial one: Hello World!][tute-one]
|
|
31
|
+
|
|
32
|
+
A "Hello World" example, with one script sending a message to a queue,
|
|
33
|
+
and another receiving messages from the same queue.
|
|
34
|
+
|
|
35
|
+
* [send.js](send.js)
|
|
36
|
+
* [receive.js](receive.js)
|
|
37
|
+
|
|
38
|
+
## [Tutorial two: Work queues][tute-two]
|
|
39
|
+
|
|
40
|
+
Using RabbitMQ as a work queue; `new_task` creates a task, and
|
|
41
|
+
`worker` processes tasks. Multiple `worker` process will share the
|
|
42
|
+
tasks among them. Long-running tasks are simulated by supplying a
|
|
43
|
+
string with dots, e.g., '...' to `new_task`. Each dot makes the worker
|
|
44
|
+
"work" for a second.
|
|
45
|
+
|
|
46
|
+
* [new_task.js](new_task.js)
|
|
47
|
+
* [worker.js](worker.js)
|
|
48
|
+
|
|
49
|
+
## [Tutorial three: Publish/Subscribe][tute-three]
|
|
50
|
+
|
|
51
|
+
Using RabbitMQ as a broadcast mechanism. `emit_log` sends a "log"
|
|
52
|
+
message to a fanout exchange, and all `receive_logs` processes receive
|
|
53
|
+
log messages.
|
|
54
|
+
|
|
55
|
+
* [emit_log.js](emit_log.js)
|
|
56
|
+
* [receive_logs.js](receive_logs.js)
|
|
57
|
+
|
|
58
|
+
## [Tutorial four: Routing][tute-four]
|
|
59
|
+
|
|
60
|
+
Using RabbitMQ as a routing ('somecast') mechanism. `emit_log_direct`
|
|
61
|
+
sends a log message with a severity, and all `receive_logs_direct`
|
|
62
|
+
processes receive log messages for the severities on which they are
|
|
63
|
+
listening.
|
|
64
|
+
|
|
65
|
+
* [emit_log_direct.js](emit_log_direct.js)
|
|
66
|
+
* [receive_logs_direct.js](receive_logs_direct.js)
|
|
67
|
+
|
|
68
|
+
## [Tutorial five: Topics][tute-five]
|
|
69
|
+
|
|
70
|
+
Extends the previous tutorial to routing with wildcarded patterns.
|
|
71
|
+
|
|
72
|
+
* [emit_log_topic.js](emit_log_topic.js)
|
|
73
|
+
* [receive_logs_topic.js](receive_logs_topic.js)
|
|
74
|
+
|
|
75
|
+
## [Tutorial six: RPC][tute-six]
|
|
76
|
+
|
|
77
|
+
Using RabbitMQ as an RPC intermediary, queueing requests for servers
|
|
78
|
+
and routing replies back to clients.
|
|
79
|
+
|
|
80
|
+
* [rpc_server.js](rpc_server.js)
|
|
81
|
+
* [rpc_client.js](rpc_client.js)
|
|
82
|
+
|
|
83
|
+
I depart slightly from the original tutorial code, which I think has
|
|
84
|
+
some needless object-orientation (in the Python code; you don't get a
|
|
85
|
+
choice about needless object-orientation in Java).
|
|
86
|
+
|
|
87
|
+
[rabbitmq-tutes]: http://github.com/rabbitmq/rabbitmq-tutorials
|
|
88
|
+
[tute-one]: http://www.rabbitmq.com/tutorials/tutorial-one-javascript.html
|
|
89
|
+
[tute-two]: http://www.rabbitmq.com/tutorials/tutorial-two-javascript.html
|
|
90
|
+
[tute-three]: http://www.rabbitmq.com/tutorials/tutorial-three-javascript.html
|
|
91
|
+
[tute-four]: http://www.rabbitmq.com/tutorials/tutorial-four-javascript.html
|
|
92
|
+
[tute-five]: http://www.rabbitmq.com/tutorials/tutorial-five-javascript.html
|
|
93
|
+
[tute-six]: http://www.rabbitmq.com/tutorials/tutorial-six-javascript.html
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
var amqp = require('amqplib/callback_api');
|
|
4
|
+
|
|
5
|
+
function bail(err, conn) {
|
|
6
|
+
console.error(err);
|
|
7
|
+
if (conn) conn.close(function() { process.exit(1); });
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function on_connect(err, conn) {
|
|
11
|
+
if (err !== null) return bail(err);
|
|
12
|
+
|
|
13
|
+
var ex = 'logs';
|
|
14
|
+
|
|
15
|
+
function on_channel_open(err, ch) {
|
|
16
|
+
if (err !== null) return bail(err, conn);
|
|
17
|
+
ch.assertExchange(ex, 'fanout', {durable: false});
|
|
18
|
+
var msg = process.argv.slice(2).join(' ') ||
|
|
19
|
+
'info: Hello World!';
|
|
20
|
+
ch.publish(ex, '', Buffer.from(msg));
|
|
21
|
+
console.log(" [x] Sent '%s'", msg);
|
|
22
|
+
ch.close(function() { conn.close(); });
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
conn.createChannel(on_channel_open);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
amqp.connect(on_connect);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
var amqp = require('amqplib/callback_api');
|
|
4
|
+
|
|
5
|
+
var args = process.argv.slice(2);
|
|
6
|
+
var severity = (args.length > 0) ? args[0] : 'info';
|
|
7
|
+
var message = args.slice(1).join(' ') || 'Hello World!';
|
|
8
|
+
|
|
9
|
+
function bail(err, conn) {
|
|
10
|
+
console.error(err);
|
|
11
|
+
if (conn) conn.close(function() { process.exit(1); });
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function on_connect(err, conn) {
|
|
15
|
+
if (err !== null) return bail(err);
|
|
16
|
+
|
|
17
|
+
var ex = 'direct_logs';
|
|
18
|
+
var exopts = {durable: false};
|
|
19
|
+
|
|
20
|
+
function on_channel_open(err, ch) {
|
|
21
|
+
if (err !== null) return bail(err, conn);
|
|
22
|
+
ch.assertExchange(ex, 'direct', exopts, function(err, ok) {
|
|
23
|
+
ch.publish(ex, severity, Buffer.from(message));
|
|
24
|
+
ch.close(function() { conn.close(); });
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
conn.createChannel(on_channel_open);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
amqp.connect(on_connect);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
var amqp = require('amqplib/callback_api');
|
|
4
|
+
|
|
5
|
+
var args = process.argv.slice(2);
|
|
6
|
+
var key = (args.length > 0) ? args[0] : 'info';
|
|
7
|
+
var message = args.slice(1).join(' ') || 'Hello World!';
|
|
8
|
+
|
|
9
|
+
function bail(err, conn) {
|
|
10
|
+
console.error(err);
|
|
11
|
+
if (conn) conn.close(function() { process.exit(1); });
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function on_connect(err, conn) {
|
|
15
|
+
if (err !== null) return bail(err);
|
|
16
|
+
var ex = 'topic_logs', exopts = {durable: false};
|
|
17
|
+
conn.createChannel(function(err, ch) {
|
|
18
|
+
ch.assertExchange(ex, 'topic', exopts, function(err, ok) {
|
|
19
|
+
if (err !== null) return bail(err, conn);
|
|
20
|
+
ch.publish(ex, key, Buffer.from(message));
|
|
21
|
+
console.log(" [x] Sent %s:'%s'", key, message);
|
|
22
|
+
ch.close(function() { conn.close(); });
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
amqp.connect(on_connect);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
var amqp = require('amqplib/callback_api');
|
|
4
|
+
|
|
5
|
+
function bail(err, conn) {
|
|
6
|
+
console.error(err);
|
|
7
|
+
if (conn) conn.close(function() { process.exit(1); });
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function on_connect(err, conn) {
|
|
11
|
+
if (err !== null) return bail(err);
|
|
12
|
+
|
|
13
|
+
var q = 'task_queue';
|
|
14
|
+
|
|
15
|
+
conn.createChannel(function(err, ch) {
|
|
16
|
+
if (err !== null) return bail(err, conn);
|
|
17
|
+
ch.assertQueue(q, {durable: true}, function(err, _ok) {
|
|
18
|
+
if (err !== null) return bail(err, conn);
|
|
19
|
+
var msg = process.argv.slice(2).join(' ') || "Hello World!";
|
|
20
|
+
ch.sendToQueue(q, Buffer.from(msg), {persistent: true});
|
|
21
|
+
console.log(" [x] Sent '%s'", msg);
|
|
22
|
+
ch.close(function() { conn.close(); });
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
amqp.connect(on_connect);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
var amqp = require('amqplib/callback_api');
|
|
4
|
+
|
|
5
|
+
function bail(err, conn) {
|
|
6
|
+
console.error(err);
|
|
7
|
+
if (conn) conn.close(function() { process.exit(1); });
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function on_connect(err, conn) {
|
|
11
|
+
if (err !== null) return bail(err);
|
|
12
|
+
process.once('SIGINT', function() { conn.close(); });
|
|
13
|
+
|
|
14
|
+
var q = 'hello';
|
|
15
|
+
|
|
16
|
+
function on_channel_open(err, ch) {
|
|
17
|
+
ch.assertQueue(q, {durable: false}, function(err, ok) {
|
|
18
|
+
if (err !== null) return bail(err, conn);
|
|
19
|
+
ch.consume(q, function(msg) { // message callback
|
|
20
|
+
console.log(" [x] Received '%s'", msg.content.toString());
|
|
21
|
+
}, {noAck: true}, function(_consumeOk) { // consume callback
|
|
22
|
+
console.log(' [*] Waiting for messages. To exit press CTRL+C');
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
conn.createChannel(on_channel_open);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
amqp.connect(on_connect);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
var amqp = require('amqplib/callback_api');
|
|
4
|
+
|
|
5
|
+
function bail(err, conn) {
|
|
6
|
+
console.error(err);
|
|
7
|
+
if (conn) conn.close(function() { process.exit(1); });
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function on_connect(err, conn) {
|
|
11
|
+
if (err !== null) return bail(err);
|
|
12
|
+
process.once('SIGINT', function() { conn.close(); });
|
|
13
|
+
|
|
14
|
+
var ex = 'logs';
|
|
15
|
+
|
|
16
|
+
function on_channel_open(err, ch) {
|
|
17
|
+
if (err !== null) return bail(err, conn);
|
|
18
|
+
ch.assertQueue('', {exclusive: true}, function(err, ok) {
|
|
19
|
+
var q = ok.queue;
|
|
20
|
+
ch.bindQueue(q, ex, '');
|
|
21
|
+
ch.consume(q, logMessage, {noAck: true}, function(err, ok) {
|
|
22
|
+
if (err !== null) return bail(err, conn);
|
|
23
|
+
console.log(" [*] Waiting for logs. To exit press CTRL+C.");
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function logMessage(msg) {
|
|
29
|
+
if (msg)
|
|
30
|
+
console.log(" [x] '%s'", msg.content.toString());
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
conn.createChannel(on_channel_open);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
amqp.connect(on_connect);
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
var amqp = require('amqplib/callback_api');
|
|
4
|
+
|
|
5
|
+
var basename = require('path').basename;
|
|
6
|
+
|
|
7
|
+
var severities = process.argv.slice(2);
|
|
8
|
+
if (severities.length < 1) {
|
|
9
|
+
console.log('Usage %s [info] [warning] [error]',
|
|
10
|
+
basename(process.argv[1]));
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function bail(err, conn) {
|
|
15
|
+
console.error(err);
|
|
16
|
+
if (conn) conn.close(function() { process.exit(1); });
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function on_connect(err, conn) {
|
|
20
|
+
if (err !== null) return bail(err);
|
|
21
|
+
process.once('SIGINT', function() { conn.close(); });
|
|
22
|
+
|
|
23
|
+
conn.createChannel(function(err, ch) {
|
|
24
|
+
if (err !== null) return bail(err, conn);
|
|
25
|
+
var ex = 'direct_logs', exopts = {durable: false};
|
|
26
|
+
|
|
27
|
+
ch.assertExchange(ex, 'direct', exopts);
|
|
28
|
+
ch.assertQueue('', {exclusive: true}, function(err, ok) {
|
|
29
|
+
if (err !== null) return bail(err, conn);
|
|
30
|
+
|
|
31
|
+
var queue = ok.queue, i = 0;
|
|
32
|
+
|
|
33
|
+
function sub(err) {
|
|
34
|
+
if (err !== null) return bail(err, conn);
|
|
35
|
+
else if (i < severities.length) {
|
|
36
|
+
ch.bindQueue(queue, ex, severities[i], {}, sub);
|
|
37
|
+
i++;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
ch.consume(queue, logMessage, {noAck: true}, function(err) {
|
|
42
|
+
if (err !== null) return bail(err, conn);
|
|
43
|
+
console.log(' [*] Waiting for logs. To exit press CTRL+C.');
|
|
44
|
+
sub(null);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function logMessage(msg) {
|
|
51
|
+
console.log(" [x] %s:'%s'",
|
|
52
|
+
msg.fields.routingKey,
|
|
53
|
+
msg.content.toString());
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
amqp.connect(on_connect);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
var amqp = require('amqplib/callback_api');
|
|
4
|
+
var basename = require('path').basename;
|
|
5
|
+
|
|
6
|
+
var keys = process.argv.slice(2);
|
|
7
|
+
if (keys.length < 1) {
|
|
8
|
+
console.log('Usage %s pattern [pattern...]',
|
|
9
|
+
basename(process.argv[1]));
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function bail(err, conn) {
|
|
14
|
+
console.error(err);
|
|
15
|
+
if (conn) conn.close(function() { process.exit(1); });
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function on_connect(err, conn) {
|
|
19
|
+
if (err !== null) return bail(err);
|
|
20
|
+
process.once('SIGINT', function() { conn.close(); });
|
|
21
|
+
|
|
22
|
+
conn.createChannel(function(err, ch) {
|
|
23
|
+
if (err !== null) return bail(err, conn);
|
|
24
|
+
var ex = 'topic_logs', exopts = {durable: false};
|
|
25
|
+
|
|
26
|
+
ch.assertExchange(ex, 'topic', exopts);
|
|
27
|
+
ch.assertQueue('', {exclusive: true}, function(err, ok) {
|
|
28
|
+
if (err !== null) return bail(err, conn);
|
|
29
|
+
|
|
30
|
+
var queue = ok.queue, i = 0;
|
|
31
|
+
|
|
32
|
+
function sub(err) {
|
|
33
|
+
if (err !== null) return bail(err, conn);
|
|
34
|
+
else if (i < keys.length) {
|
|
35
|
+
ch.bindQueue(queue, ex, keys[i], {}, sub);
|
|
36
|
+
i++;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
ch.consume(queue, logMessage, {noAck: true}, function(err) {
|
|
41
|
+
if (err !== null) return bail(err, conn);
|
|
42
|
+
console.log(' [*] Waiting for logs. To exit press CTRL+C.');
|
|
43
|
+
sub(null);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function logMessage(msg) {
|
|
50
|
+
console.log(" [x] %s:'%s'",
|
|
51
|
+
msg.fields.routingKey,
|
|
52
|
+
msg.content.toString());
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
amqp.connect(on_connect);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
var amqp = require('amqplib/callback_api');
|
|
4
|
+
var basename = require('path').basename;
|
|
5
|
+
var uuid = require('node-uuid');
|
|
6
|
+
|
|
7
|
+
var n;
|
|
8
|
+
try {
|
|
9
|
+
if (process.argv.length < 3) throw Error('Too few args');
|
|
10
|
+
n = parseInt(process.argv[2]);
|
|
11
|
+
}
|
|
12
|
+
catch (e) {
|
|
13
|
+
console.error(e);
|
|
14
|
+
console.warn('Usage: %s number', basename(process.argv[1]));
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function bail(err, conn) {
|
|
19
|
+
console.error(err);
|
|
20
|
+
if (conn) conn.close(function() { process.exit(1); });
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function on_connect(err, conn) {
|
|
24
|
+
if (err !== null) return bail(err);
|
|
25
|
+
conn.createChannel(function(err, ch) {
|
|
26
|
+
if (err !== null) return bail(err, conn);
|
|
27
|
+
|
|
28
|
+
var correlationId = uuid();
|
|
29
|
+
function maybeAnswer(msg) {
|
|
30
|
+
if (msg.properties.correlationId === correlationId) {
|
|
31
|
+
console.log(' [.] Got %d', msg.content.toString());
|
|
32
|
+
}
|
|
33
|
+
else return bail(new Error('Unexpected message'), conn);
|
|
34
|
+
ch.close(function() { conn.close(); });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
ch.assertQueue('', {exclusive: true}, function(err, ok) {
|
|
38
|
+
if (err !== null) return bail(err, conn);
|
|
39
|
+
var queue = ok.queue;
|
|
40
|
+
ch.consume(queue, maybeAnswer, {noAck:true});
|
|
41
|
+
console.log(' [x] Requesting fib(%d)', n);
|
|
42
|
+
ch.sendToQueue('rpc_queue', Buffer.from(n.toString()), {
|
|
43
|
+
replyTo: queue, correlationId: correlationId
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
amqp.connect(on_connect);
|