postwait/node-amqp — Issue #69: Following sample code desn not work - 
Author: RajanBhatt
Created: 2012-02-15 00:38:13+00:00
State: open

Hello,

I just npm install amqp and when I do npm list I get following modules installed.amqp@.0.1.2
I tried to run following code which comes bundled with source ...

I get following error ..

q.bind.addCallback undefined...

Any idea ? Is it supposed to work ?

Any sample code which works with this package or I should install some other package

Thanks
Rajan

var amqp = require('./amqp');

var connection = amqp.createConnection({host: 'localhost'});

connection.addListener('close', function (e) {
if (e) {
throw e;
} else {
console.log('connection closed.');
}
});

connection.addListener('ready', function () {
console.log("connected to " + connection.serverProperties.product);

var exchange = connection.exchange('clock', {type: 'fanout'});

var q = connection.queue('my-events-receiver');

q.bind(exchange, "*").addCallback(function () {
console.log("publishing message");
exchange.publish("message.json", {hello: 'world', foo: 'bar'});
exchange.publish("message.text", 'hello world', {contentType: 'text/plain'});
});

q.subscribe(function (m) {
console.log("--- Message (" + m.deliveryTag + ", '" + m.routingKey + "') ---");
console.log("--- contentType: " + m.contentType);

m.addListener('data', function (d) {
console.log(d);
});

m.addListener('end', function () {
m.acknowledge();
console.log("--- END (" + m.deliveryTag + ", '" + m.routingKey + "') ---");
});
});
});