You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
590 B
22 lines
590 B
var amqp = require('../'); |
|
|
|
var NUM_MSGS = 20; |
|
|
|
function mkCallback(i) { |
|
return (i % 2) === 0 ? function(err) { |
|
if (err !== null) { console.error('Message %d failed!', i); } |
|
else { console.log('Message %d confirmed', i); } |
|
} : null; |
|
} |
|
|
|
amqp.connect().then(function(c) { |
|
c.createConfirmChannel().then(function(ch) { |
|
for (var i=0; i < NUM_MSGS; i++) { |
|
ch.publish('amq.topic', 'whatever', new Buffer('blah'), {}, mkCallback(i)); |
|
} |
|
ch.waitForConfirms().then(function() { |
|
console.log('All messages done'); |
|
c.close(); |
|
}, console.error); |
|
}); |
|
});
|
|
|