Job queue in node.js

偶尔善良 提交于 2019-12-06 03:00:09

问题


I'm looking for a job queue manager in node.js which can be invoked by php. This is for a web application which needs to send emails, create pdf files and so on which I'd like to perform asynchronous of the php process.

Example of the process:

  1. User requests a php page
  2. Php invokes the job queue manager and adds a task
  3. Task is executed in node.js asynchronously of php, preferably when it's a bit more quiet
  4. Task is to execute a php script

Why this "complex" system?

  1. We write all our web-applications in php (Zend Framework)
  2. We'd like to start learning node.js
  3. We need a asynchronous process (fast response!)
  4. The "real" task should be a php script as well, to utilize already written php classes, to have easy access to database connections and be as much DRY as possible

Use cases of this system:

  1. User registers himself, system will send welcome email
  2. User completes ecommerce order, system will send invoice

In the end, we'd like to use node-cron as well, to perform non-system wide cron tasks (very application specific). Node-cron will invoke the job queue manager, which will subsequently run a php script.

Is there such an application already in node?


回答1:


One possible options is node-jobs, which uses Redis.




回答2:


In such a case I would prefer a message queue like RabbitMQ and client side libraries like node-amqp and php-amqp. Then simply send your job from your PHP script in the queue and let nodejs pick up the job from the queue. A big advantage is that it is extensible and it is widely used and tested in the enterprise market.



来源:https://stackoverflow.com/questions/7384166/job-queue-in-node-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!