简体   繁体   English

如何使用RabbitMQ在预定时间运行任务

[英]how to run task at scheduled time with RabbitMQ

I'm using RabbitMQ to make my tasks pool run sequentially one by one.我正在使用RabbitMQ使我的任务池一项一项地按顺序运行。 But how can add a time parameter to make a task only run at the defined time in the future (like a scheduled tasks ).但是如何添加时间参数以使任务仅在未来定义的时间运行(如scheduled tasks )。

RabbitMQ is not a task scheduler, even though the documentation talks about "scheduling" a task. RabbitMQ 不是任务调度程序,尽管文档中谈到了“调度”任务。 You might consider using something like cron.您可能会考虑使用像 cron 这样的东西。 You could also use a library like sched to build a scheduler in a Python process.您还可以使用sched 之类的库在 Python 进程中构建调度程序。

FYI It looks like this question has already been answered: Delayed message in RabbitMQ仅供参考 看来这个问题已经得到了回答: RabbitMQ 中的延迟消息

RabbitMQ has a plugin for delayed messages . RabbitMQ 有一个用于 延迟消息的插件。

Using this plugin, the messages can be delivered to the respective queues after a certain delay.使用此插件,消息可以在一定延迟后传送到相应的队列。 Thanks to this plugin, you can use RabbitMQ as a scheduler, even though it's not a task scheduler by nature.多亏了这个插件,您可以将 RabbitMQ 用作调度程序,即使它本质上不是任务调度程序。

You can use celery along with rabbitmq as broker for task scheduling.您可以将 celery 与 rabbitmq 一起用作任务调度的代理。 Here is the celery documentation http://docs.celeryproject.org/en/master/index.html这是芹菜文档http://docs.celeryproject.org/en/master/index.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM