如何使用 PHP 集成 AWS SWF,以便可以从用户界面对其进行管理?

How to integrate AWS SWF using PHP so it can be managed from a user interface?

我正在使用 LAMP 构建一个 CMS,允许管理员将 MP4 上传到 Amazon S3 存储桶,使用 Elastic Transcoder 对其进行多次转换,并更新本地数据库以便使用云锋。

现在每个步骤都按预期工作,一个简单的 SWF 工作流将所有步骤连接起来(只要我从命令行启动启动程序、决策程序和 activity 工作程序,正如我在示例中看到的那样无处不在)。

但是,我正在努力将各个部分与用户界面连接起来:

编辑:有人可能会发现这对第 2 点有用:

Program the activity worker to poll for another activity task after it has completed the task at hand. This creates a loop where the activity worker continuously polls for and completes tasks.

Until the decider schedules activity tasks, though, these polls time out with no tasks and your workers just continue polling.

If no decision task is available, Amazon SWF holds the connection open for up to 60 seconds, and returns a task as soon as it becomes available. If no task becomes available, Amazon SWF returns an empty response [...] Make sure to program your decider to poll for another task if it receives an empty response.

我会建议 运行 activity 和决策者工作人员永久独立于 Web 服务器进程。您可以将它们作为守护进程启动。他们应该循环轮询新任务并根据您的逻辑处理它们。因此任务执行完成后无需再次启动它们。

工作流实例从网络服务器进程启动,因为启动它们是一个相对快速的调用,不会等待工作流执行完成。

在 UI 中实施反馈通常是通过网络服务器代码轮询特殊 activity 类型(如 "UIFeedback")来完成的。当工作流需要通知 UI 某事时,它会安排此 activity 发送到网络服务器,网络服务器将 activity 输入数据转发到 AJAX 代码。