node-amqp icon indicating copy to clipboard operation
node-amqp copied to clipboard

exchange.publish in confirm mode doesn't trigger callback on a error

Open rimassa opened this issue 12 years ago • 6 comments

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

rimassa avatar Jan 11 '13 13:01 rimassa

It should call my callback passing failed=true so I can be noticed about the failure, right? Thanks

rimassa avatar Jan 11 '13 13:01 rimassa

Confirmed in version 1.7 on node v0.10.21

nekinie avatar Nov 04 '13 14:11 nekinie

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"

stowns avatar Nov 20 '13 20:11 stowns

FYI, our solution was to use the packaged release from Github and not the one on NPM, hope it helps

nekinie avatar Nov 21 '13 09:11 nekinie

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.

stowns avatar Nov 21 '13 18:11 stowns

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.

jensbjork avatar Sep 24 '14 11:09 jensbjork