设计基于消息的处理系统

发布于 2024-08-23 14:43:31 字数 359 浏览 6 评论 0原文

我正在设计一个基于 RabbitMQ 的消息处理系统,用于各种基于 PHP 的 Web 应用程序。 PHP 守护进程将用于从队列中检索项目并执行处理。

例如,这个想法是,向数百个收件人发送电子邮件,消息队列将异步执行到 Web 应用程序。

最佳方法是什么,

  1. 我的问题是,对于这种类型的系统,检测电子邮件发送进度的
  2. 即(2/100)知道整个过程何时完成。
  3. 当 2 已知时,当整个过程完成时将消息发送回 Web 应用程序?

对于第 1 项,我认为守护进程会向完成队列发送一条消息,但是第 2 项和第 3 项的代码将放在哪里?

希望这是有道理的。

K

I am designing a RabbitMQ based message processing system for use with various PHP based web applications. PHP daemons will be used to retrieve items from a queue and perform processing.

The idea is for example, emailing hundreds of receipients, the message queue will do it asyncronously to the web application.

My question is, with this type of system, what would be the best way to

  1. Detect the progress of emails sent ie (2/100)
  2. Know when the entire process is complete.
  3. When 2 is known, send a message back to the web application when the entire process is complete?

For 1, I think the daemon would send a message to a completion queue, but where would the code for items 2 and 3 be placed?

Hope that makes sense.

K

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

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

发布评论

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

评论(1

郁金香雨 2024-08-30 14:43:31

看起来你需要事件处理:)... PHP(与 Java 不同)不提供事件处理,所以我能看到的唯一选项是让网络服务器轮询守护进程。或者,守护进程可以将完成状态写入静态文件,该文件可以由网络服务器轮询(性能略有提高)。轮询器可以是一个 javascript 无限循环(成功类型中断),它不断向文件或网络服务器发出 ajax 请求。

您还可以查看 Comet(服务器推送)方法,其中守护进程可以在完成后将数据推送到服务器。

如果这有帮助或者您需要任何其他详细信息,请告诉我。

问候
皮纳基

Looks like you need eventing :)... PHP (unlike Java) does not provide eventing, so the only option I can see is for the webserver to poll the daemon process. Alternatively, the daemon can write the completion status to a static file which can be polled by the webserver (a little performance improvement). The poller could be a javascript infinite loop (break on success type) which keeps making the ajax request to the file or webserver.

You can also look at Comet (server push) method, where the daemon can push the data to the server on completion.

Let me know if this helps or you need any other details.

regards
pinaki

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