What's the equivalent of Laravel queue jobs in Express?

Viewed 1484

Laravel offers a feature called Queues where you delegate long running task to a background worker using a service (beanstalkd, Amazon SQS, Rabbit MQ). A quick example would be sending an email through that queued job, instead of from the controller. Said queued job is able to identify whether the task was completed, or, if it failed, retry a certain amount of times.

What's the Express (NodeJS) equivalent of this feature (if it even exists)? I tried researching the topic by directly looking for resources on the service (like RabbitMQ) and I only found tutorial like this one, but just by reading it looks like they're implementing the thing from the ground.

Maybe my expectations are what's wrong in here, but isn't there an equivalent of just writing the business logic code for the queued job and dispatching it?

2 Answers

It is an old question but since we have tried several queues solutions both with laravel and nodejs I would like share some experience.

First of all, laravel queue worker normally uses redis. Each job is RPUSHed into redis List or ZADDed into ZSET. It does not use a message queue like RabbitMQ. I will argue that using RabbitMQ is "over-qualify" for this task. Here is an article talking about switch from RabbitMQ to Redis for their queue implementation, to quote "While RabbitMQ did the job and did it well, we decided that we will convert all our RabbitMQ queues to Redis. We switched completeness for simplicity and versatility (obviously for caching & K/V purpose)."

The Express (NodeJS) equivalent of this feature is bull or bee queue. They both use redis like laravel queue does. I didn't try kue because I feel it is too old.

I finally chose bull over bee because I can't find an easy way to pause/cancel a job in bee. I also feel bull is more actively maintained than bee.

It may be worth to mention that there is a npm package called queue which implements the queue just base on Array. It doesn't apply to my use cases though.

Related