问题
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:
- User requests a php page
- Php invokes the job queue manager and adds a task
- Task is executed in node.js asynchronously of php, preferably when it's a bit more quiet
- Task is to execute a php script
Why this "complex" system?
- We write all our web-applications in php (Zend Framework)
- We'd like to start learning node.js
- We need a asynchronous process (fast response!)
- 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:
- User registers himself, system will send welcome email
- 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