node-amqp
node-amqp copied to clipboard
exchange.publish in confirm mode doesn't trigger callback on a error
Hi
Suppose I get a successful connection to my rabbit server and a handler to an exchange myExchange. If I run the code below, node-amqp calls my callback passing failed=false. But if I stop my rabbit server right before calling it, the callback is never called.
myExchange.publish(topic, message, cfg.rabbitMQ.publishOptions, function (failed) { console.log('Failed: ', failed) });
Thanks Ricardo
It should call my callback passing failed=true so I can be noticed about the failure, right? Thanks
Confirmed in version 1.7 on node v0.10.21
My callback is not called regardless of success or failure which is troublesome because I need to close the connection
connect = AQMP.createConnection({ host : @host });
connect.on 'ready', ->
console.log 'RabbitMQProducer: READY'
connect.exchange _this.exchange, {type: 'direct', confirm:true}, (ex) ->
console.log 'RabbitMQProducer Exchange Open!'
ex.publish _this.key, JSON.stringify(message), {deliveryMode: 2}, (err) ->
# never called
console.log 'Calling Connect END!'
connect.end()
"version": "0.1.7"
FYI, our solution was to use the packaged release from Github and not the one on NPM, hope it helps
Pulling the latest release https://github.com/postwait/node-amqp/releases/tag/v0.1.7 has no impact on the code I posted above. The cb is fired from connection.publish() but not exchange.publish(). My workaround is to call connect.end() just after ex.publish rather than with-in the callback. My concern is that in some cases the connection will close before ack'ing by the consumer takes place.
I can confirm that the callback does not seem to fire in connection.publish(...) nor in connection.exchange.publish(...). Running version 0.2.0 through npm.