Skip to content

Commit 01bb66e

Browse files
slim-hmidilukebakken
authored andcommitted
update the varibales names
update the Readme.md Update amqplib dependency, run js-beautify and jshint on emit_log.js run js-beautify and jshint on send.js, receive.js run js-beautify and jshint on all js files
1 parent 9907aa7 commit 01bb66e

15 files changed

+580
-196
lines changed

javascript-nodejs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ To install `amqp.node` using npm:
5252
[Tutorial six: RPC](https://www.rabbitmq.com/tutorials/tutorial-six-javascript.html):
5353

5454
node src/rpc_server.js
55-
node src/rpc_client.js
55+
node src/rpc_client.js 30

javascript-nodejs/package-lock.json

Lines changed: 256 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

javascript-nodejs/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "1.0.0",
44
"description": "RabbitMQ amqp.node tutorial ",
55
"dependencies": {
6-
"amqplib": "^0.3.2"
6+
"amqplib": "latest",
7+
"js-beautify": "^1.9.1"
78
}
89
}

javascript-nodejs/src/emit_log.js

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,26 @@
22

33
var amqp = require('amqplib/callback_api');
44

5-
amqp.connect('amqp://localhost', function(err, conn) {
6-
conn.createChannel(function(err, ch) {
7-
var ex = 'logs';
8-
var msg = process.argv.slice(2).join(' ') || 'Hello World!';
5+
amqp.connect('amqp://localhost', function(error0, connection) {
6+
if (error0) {
7+
throw error0;
8+
}
9+
connection.createChannel(function(error1, channel) {
10+
if (error1) {
11+
throw error1;
12+
}
13+
var exchange = 'logs';
14+
var msg = process.argv.slice(2).join(' ') || 'Hello World!';
915

10-
ch.assertExchange(ex, 'fanout', {durable: false});
11-
ch.publish(ex, '', new Buffer(msg));
12-
console.log(" [x] Sent %s", msg);
13-
});
16+
channel.assertExchange(exchange, 'fanout', {
17+
durable: false
18+
});
19+
channel.publish(exchange, '', Buffer.from(msg));
20+
console.log(" [x] Sent %s", msg);
21+
});
1422

15-
setTimeout(function() { conn.close(); process.exit(0) }, 500);
23+
setTimeout(function() {
24+
connection.close();
25+
process.exit(0);
26+
}, 500);
1627
});

0 commit comments

Comments
 (0)