Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How should I do this in Node.js

How should I do this in Node.js


I am a bit stuck with how I should implement this in Node.js. Here's the scenario:

In my Database, I have bunch of "tasks". These tasks are suppose to do some asynchronous IO. I want to loop through these tasks infinitely and perform them like a Queue. When a task is done, it goes back to the queue.

I loop through the database result of all tasks, if the task is already in the queue, i skip, otherwise i add it to the queue.

What's the best way to do this in Node.js?


Problem courtesy of: 0xSina


The best way to achieve this is by using Kue. Not only will it help you putting all your tasks in a queue and execute them, but you can also have multiple processes (workers) executing jobs.

Here's a nice tutorial about it:

Solution courtesy of: alessioalex


View additional discussion.

This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

How should I do this in Node.js


Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription