dongzhugao9929 2015-08-26 14:04 采纳率: 0%
浏览 42

在nack冻结我的应用程序之前删除队列

I'm kind of new to rabbitmq and i was wondering what is the best way to handle an error I'm having when a delete a queue before I can ack a delivery on that queue.

if err := handle(); err != nil {
  delivery.Nack(false, true)
} else {
  delivery.Ack(false)
}

The problem with this code is that our queues are created/deleted based on a coordinator external to our dispatcher, so when delivery is Nack and the queue was deleted the system hangs because it keeps trying to requeue the delivery.

To solve the problem I can just check if the:

delivery.Nack(false, true)

returns an error and I can handle it there. But what would be the best approach to drop this delivery if the Nack method returned an error?

Note: I'm using https://github.com/streadway/amqp

  • 写回答

1条回答 默认 最新

  • doushi1912 2015-08-26 14:41
    关注

    The problem with this code is that our queues are created/deleted based on a coordinator external to our dispatcher,

    that is the problem, right there. i would question why you want to do this, instead of allowing the consumer to define the queue and binding that it needs?

    barring the ability to question / change that, an error handler around the deliver.Nack is probably your best option. but i think that's an unpleasant workaround for a problem caused by larger design issue

    评论

报告相同问题?