dropbox / amqp-coffee

An AMQP 0.9.1 client for Node.js.
MIT License
79 stars 30 forks source link

Handle method.basicCancel #52

Closed AVVS closed 8 years ago

AVVS commented 8 years ago

When we have the following options and #51 is merged in consumer gets new events

{
      host: 'localhost',
      port: 5672,
      login: 'guest',
      password: 'guest',
      vhost: '/',
      temporaryChannelTimeout: 6000,
      clientProperties: {
        capabilities: {
          consumer_cancel_notify: true,
        },
      },
},

Example log:

  amqp:AMQPParser 2 > method basicCancel {"consumerTag":"Vitalys-iMac.local-30767-1452811088079","noWait":1} +20s
  amqp:Consumer onMethod basicCancel, {"consumerTag":"Vitalys-iMac.local-30767-1452811088079","noWait":1} +1ms

It would be nice to have https://github.com/dropbox/amqp-coffee/blob/master/src/lib/Consumer.coffee#L196 extended with a handler for such an event (https://www.rabbitmq.com/consumer-cancel.html). It could simply emit an event, which a user must handle, or automatically try to reconnect. To synthetically generate such an event - create a consumer and then purge queue/exchange in the rabbitmq management console

barshow commented 8 years ago

What would you want it to do? I suppose emitting an error on the consumer could work?

AVVS commented 8 years ago

Maybe another kind or event such as 'cancel'? Error would, of course, work, but then we'll have to choose error code, structure it similarly to rabbitmq response, and this is likely undesirable

On 15 Jan 2016, at 01:53, David Barshow notifications@github.com wrote:

What would you want it to do? I suppose emitting an error on the consumer could work?

— Reply to this email directly or view it on GitHub.

barshow commented 8 years ago

yeah, i really hate adding random emitters, everything but errors are callback based. I think ill add the cancel listener and fall back to error if there isn't a cancel listener.