具有延迟的简单可扩展工作/消息队列

发布于 2024-08-23 15:55:56 字数 174 浏览 5 评论 0原文

我需要设置一个作业/消息队列,并可以选择为任务设置延迟,以便空闲工作人员不会立即拾取它,而是在一定时间后(可能因任务而异)。我研究了几个 Linux 队列解决方案(rabbitmq、gearman、memcacheq),但它们似乎都没有提供开箱即用的此功能。

关于如何实现这一目标有什么想法吗?

谢谢!

I need to set up a job/message queue with the option to set a delay for the task so that it's not picked up immediately by a free worker, but after a certain time (can vary from task to task). I looked into a couple of linux queue solutions (rabbitmq, gearman, memcacheq), but none of them seem to offer this feature out of the box.

Any ideas on how I could achieve this?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

几味少女 2024-08-30 15:55:56

我使用 BeanstalkD 效果非常好,在插入新作业时使用延迟选项等待几秒钟,直到该项目可供保留。

如果您正在执行较长时间的延迟(超过 30 秒),或者作业对于执行来说有些重要(稍后),那么它还有一个二进制日志系统,以便任何守护进程崩溃仍然会有该作业的记录。也就是说,我已经通过 Beanstalkd 实例放置了数十万个实时作业,而我编写的工作程序总是比服务器出现更多问题。

I've used BeanstalkD to great effect, using the delay option on inserting a new job to wait several seconds till the item becomes available to be reserved.

If you are doing longer-term delays (more than say 30 seconds), or the jobs are somewhat important to perform (abeit later), then it also has a binary logging system so that any daemon crash would still have a record of the job. That said, I've put hundreds of thousands of live jobs through Beanstalkd instances and the workers that I wrote were always more problematical than the server.

时光暖心i 2024-08-30 15:55:56

您可以使用 AMQP 代理(例如 RabbitMQ),并且我有一个“代理”(例如使用 pyton-amqplib 构建的 python 进程),它位于交换器上并拦截特定消息(特定 routing_key);一旦计时器到了,就使用不同的routing_key在交换机上发回消息。

我意识到这意味着“翻译/映射”路由键,但它确实有效。使用 RabbitMQ 和 python-amqplib 非常简单。

You could use an AMQP broker (such as RabbitMQ) and I have an "agent" (e.g. a python process built using pyton-amqplib) that sits on an exchange an intercepts specific messages (specific routing_key); once a timer has elapsed, send back the message on the exchange with a different routing_key.

I realize this means "translating/mapping" routing keys but it works. Working with RabbitMQ and python-amqplib is very straightforward.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文