5

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?

Jurian Sluiman
  • 13,498
  • 3
  • 67
  • 99

2 Answers2

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.

mlegenhausen
  • 317
  • 2
  • 4
  • 1
    Why would you use such a tool for this setup? It seems like it could work, but over-engineered for this goal. Thorough tests and ready for enterprise market are of course advantages, but ease of use and simplicity count as well imho. – Jurian Sluiman Sep 16 '11 at 10:48
  • RabbitMQ is well documented, language independent (today it is nodejs the next day python, ruby, java?), active community. Of cause simplicity is always nice, but I choose my technologies also by the activity of the project. – mlegenhausen Sep 16 '11 at 12:03
0

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

Femi
  • 64,273
  • 8
  • 118
  • 148
  • Redis is afaik a system wide install. How would we be able to make node-jobs (which I hope can run on a per application base) use redis per application? Or should we make this easy by prefixing all jobs by the application name (probably a reverse TLD)? – Jurian Sluiman Sep 12 '11 at 07:19
  • 1
    A prefix would probably work: the reverse TLD is a neat trick. – Femi Sep 12 '11 at 08:05