Permalink
Browse files

Bits and pieces I noticed while porting tutorials to callback API

  • Loading branch information...
1 parent 729a3fb commit 7c9ce936794316f952813cdc875742a19421dfa5 @squaremo committed Apr 30, 2014
Showing with 4 additions and 5 deletions.
  1. +2 −3 examples/tutorials/callback_api/receive.js
  2. +1 −1 examples/tutorials/new_task.js
  3. +1 −1 examples/tutorials/worker.js
@@ -3,12 +3,11 @@
var amqp = require('amqplib/callback_api');
function on_connect(err, conn) {
- var q = 'hello';
-
if (err !== null) return console.error(err);
-
process.once('SIGINT', function() { conn.close(); });
+ var q = 'hello';
+
function on_channel_open(err, ch) {
ch.assertQueue(q, {durable: false}, function(err, ok) {
if (err !== null) return console.error(err);
@@ -10,7 +10,7 @@ amqp.connect('amqp://localhost').then(function(conn) {
var ok = ch.assertQueue(q, {durable: true});
return ok.then(function() {
- var msg = process.argv.slice(2).join(' ') || "Hello World!"
+ var msg = process.argv.slice(2).join(' ') || "Hello World!";
ch.sendToQueue(q, new Buffer(msg), {deliveryMode: true});
console.log(" [x] Sent '%s'", msg);
return ch.close();
@@ -4,7 +4,7 @@
var amqp = require('amqplib');
amqp.connect('amqp://localhost').then(function(conn) {
- conn.once('SIGINT', function() { conn.close(); });
+ process.once('SIGINT', function() { conn.close(); });
return conn.createChannel().then(function(ch) {
var ok = ch.assertQueue('task_queue', {durable: true});
ok = ok.then(function() { ch.prefetch(1); });

0 comments on commit 7c9ce93

Please sign in to comment.