如何恢复 RabbitMQ 队列



我们使用 RabbitMQ 执行芹菜任务。我们有一个队列操作超过 230000 个任务,该任务昨天崩溃了,日志如下,

<code>2019-02-11 22:30:32,770 WARNING 13003 [celery.worker.consumer] consumer.py:289 - consumer: Connection to broker lost. Trying to re-establish the connection...
Traceback (most recent call last):
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/celery/worker/consumer.py", line 278, in start
    blueprint.start(self)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/celery/bootsteps.py", line 123, in start
    step.start(parent)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/celery/worker/consumer.py", line 821, in start
    c.loop(*c.loop_args())
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/celery/worker/loops.py", line 70, in asynloop
    next(loop)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/kombu/async/hub.py", line 340, in create_loop
    cb(*cbargs)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/kombu/transport/base.py", line 164, in on_readable
    reader(loop)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/kombu/transport/base.py", line 146, in _read
    drain_events(timeout=0)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/amqp/connection.py", line 324, in drain_events
    return amqp_method(channel, args)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/amqp/channel.py", line 1647, in _basic_cancel_notify
    raise ConsumerCancelled(consumer_tag, (60, 30))
ConsumerCancelled: Basic.cancel: (0) None8
2019-02-11 22:30:32,878 INFO 13003 [celery.worker.consumer] consumer.py:479 - Connected to amqp://celery:**@127.0.0.1:5672//
2019-02-11 22:31:20,308 ERROR 13003 [celery.worker.consumer] consumer.py:364 - consumer: Cannot connect to amqp://celery:**@127.0.0.1:5672//: [Errno 104] Connection res$
Trying again in 2.00 seconds...
</code>

崩溃的rabbitmq后,我使用以下命令再次重新启动:

sudo service rabbitmq-server restart

一旦 rabbitmq 重新启动,我就失去了所有队列。我的队列持久性为持久,消息传递模式为非持久性。

有什么方法可以恢复队列中的消息吗?它有非常重要的用户数据正在处理中。

不。非持久性意味着它们位于 RAM 中,而不是存储在磁盘上。

一般性评论 - RabbitMQ 不是数据库。即使您已将队列设置为持久,期望消息代理可靠地处理 200,000 条消息的临时存储也是疯狂的。您的系统应设计为代理是任务之间的缓冲区,平均队列长度为零。如果发现如此大的数字,请加快处理速度或存储在数据库中,该数据库旨在能够在偶尔的重新启动中幸存下来,几乎没有后果。

相关内容

  • 没有找到相关文章

最新更新