amqp queue_delete 以异步方式捕获错误
我刚刚开始将 pika(v 0.9.4) 与 Tornado 一起使用(通过使用 pika.adapters.tornado_connection.TornadoConnection
),我想知道使用时捕获错误的适当方法是什么,当您尝试删除的队列不存在时,请说:queue_delete
。 RabbitMQ 引发 AMQPError,但我不确定如何以异步方式处理它。
有人对此有任何见解吗?
I've just got started using pika(v 0.9.4) with Tornado (through the use of pika.adapters.tornado_connection.TornadoConnection
) and I was wondering what's the appropriate way of catching errors when using, say: queue_delete
for when the queue you're trying to delete doesn't exist. RabbitMQ raises AMQPError, but I am not sure how this can be handled in an async way.
Anyone has any insights on this ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
免责声明:我是 Stormed-amqp 的作者
,我建议尝试使用 stormed-amqp
Disclaimer: I'm the author of stormed-amqp
I would suggest trying with stormed-amqp
尽量避免错误。如果您声明与队列的连接,但该连接不存在,则会创建该连接。然后立即删除。
或者,如果您将在下周左右再次使用该队列,即它不是一次性使用,则只需将其保留并作为系统管理活动处理删除,以清理长期空闲队列。
或者只需使用自动删除属性声明您的队列,当您断开连接时它们就会消失。
Try to avoid the error. If you declare a connection to the queue, and it doesn't exist, it will be created. Then immediately delete it.
Or, if you will use that queue again in the next week or so, i.e. it is not single-use, then just leave it around and handle deletion as a system admin activity that cleans up long term idle queues.
Or just declare your queues with the auto-delete attribute and they will go away when you disconnect.