Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Job queue in node.js

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?

like image 370
Jurian Sluiman Avatar asked Nov 05 '22 14:11

Jurian Sluiman


1 Answers

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.

like image 95
mlegenhausen Avatar answered Nov 09 '22 11:11

mlegenhausen