I am using node AMQP module to connect to RabbitMQ. I am able to connect, create an exchange, queue and able to send/publish the message to the exchange. I can confirm the messages are published on the management console.
Problem is I am not receiving the callback for exchange publish call. This is my code.
Initialization: (app is the express.js instance)
app.rabbitMQConnection = amqp.createConnection({ host: 'myurl.com', login: 'login', password: 'pwd' });
app.rabbitMQConnection.on('ready', function(){
console.log("RabbitMQ server connected");
app.rabbitMQConnection_e = app.rabbitMQConnection.exchange('my-exchange', { confirm: true, durable: true, autoDelete: false }, function (q) {
app.rabbitMQConnection_q_lisorders = app.rabbitMQConnection.queue('shoe-orders', {autoDelete: false, durable: true}, function (q) {
app.rabbitMQConnection_q_lisorders.bind(app.rabbitMQConnection_e, '#');
});
});
});
Then when I need to send a message I use:
app.rabbitMQConnection_e.publish('routingKey', { message: myMessage }, { deliveryMode: 2 }, function(transmissionFailed){
if (transmissionFailed == true){
console.log("message failed");
}else{
console.log("message sent");
}
});
Callback function(transmissionFailed) is never called. Please help!