Cake 3.x如何为作业和新闻提要设置队列技术? [英] Cake 3.x How to setup a queue technology for jobs and news feeds?

查看:97
本文介绍了Cake 3.x如何为作业和新闻提要设置队列技术?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Cake 3.x

I am using Cake 3.x

我需要进行以下设置.

  1. 作业队列,用于将需要长时间处理的作业排入后台
  2. 一种供稿(例如Facebook供稿),可通知各种用户应用程序中发生的事情

这是我的要求:

工作队列

这需要持久且可靠.意思是说,如果服务器突然重新启动,则所有排队但尚未执行的作业仍将在那里等待重新启动.

This needs to be persistent and reliable. Meaning to say if the server suddenly rebooted, any jobs queued but not yet executed will still be there waiting to be processed upon reboot.

新闻订阅源/活动流

这不必是持久的,可以延迟.就像Facebook.基本上是显示已发生的事件.

This need not be persistent and can be delayed. Just like Facebook. Basically it's to display events that have happened.

类似

User1 commented on your post. (2 seconds ago)
User2 liked your post. (3 mins ago)
User2 & User1 favorited your post (5 mins ago)

在Cake3 Web应用程序的上下文中应该使用哪个队列?

我应该使用哪种队列技术

What queue technology should I use for

  1. 作业队列(需要持久性,作业顺序也很重要)
  2. 新闻提要/活动流(不需要持久性,顺序并不重要)

在Cake 3.x Web应用程序的上下文中?

within the context of a Cake 3.x web app?

我是排队技术的新手.我很高兴甚至使用诸如Amazon Message Queuing Service(SQS)之类的云计算队列服务.

I am a newbie to queue technology. I am happy to use even cloud computing queue services like Amazon Message Queuing Service (SQS).

我希望有一个与CakePHP 3.x架构配合使用的解决方案.也许是CakePHP插件?

I would prefer a solution that works well with CakePHP 3.x architecture. Perhaps a CakePHP plugin?

我还可以设置2种不同的队列技术来满足2种不同的需求.

I am also okay to setup 2 different queue technologies to satisfy the 2 different requirements.

推荐答案

一个流行的Cakephp插件,支持Cake 2& 3: https://github.com/dereuromark/cakephp-queue

A popular Cakephp plugin that supports Cake 2 & 3: https://github.com/dereuromark/cakephp-queue

我相信它非常适合您的工作队列.但是,从头开始编写一个代码并不难.您可能具有一个具有以下属性的表,例如:job_type,priority,min_execute_date,completed等.然后安排一个cron作业以执行您自己的自定义Shell,该Shell将查询该表并查找优先级最高的作业.还没完成它将检查job_type并运行相关任务.如果它们成功完成,则将其标记为已完成.这种设置永远不会错过任何工作.

I believe it would suit you well for your job queue. However, it wouldn't be too difficult to code one from scratch. You could have a table with the following attributes, for instance: job_type, priority, min_execute_date, completed, etc. Then schedule a cron job to execute a custom Shell of your own that would query that table and look for jobs with the highest priority that haven't completed yet. It would check the job_type and run the relevant tasks. If they successfully complete, mark them as completed. This setup wouldn't ever miss a job.

新闻提要可能类似,但我认为您不需要调度程序.只需将其合并到您的应用程序逻辑中即可.您将拥有一个新闻提要,该新闻提要只是最新项目的运行列表.您所说的听起来像是通知.对于通知,您只需将其单击或查看即可设置为已查看,这时您可以将其从列表中删除或设置样式.

The news feed could be similar but I don't think you would need a scheduler. Just incorporate it into your application logic. You'd have a newsfeed that would just be a running list of the most recent items. What you are speaking of sounds like notifications. For notifications you could just set them as viewed once they click on them or view them, which at that point you could either remove them from the list or style them.

这篇关于Cake 3.x如何为作业和新闻提要设置队列技术?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆