Skip to content

Demo using bullmq in node.js to process periodic and async jobs

Notifications You must be signed in to change notification settings

MadeByBread/bullmq-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bullmq Example

This example demonstrates how one can do two things with bullmq:

  1. Set up a periodic, cron-like task that runs on an interval
  2. Set up an async task that gets kicked off when one makes a request to an api endpoint

Getting started

$ npm install
$
$ # Run each of these next 3 commands in their own terminal windows:
$
$ # 1. Starts a local docker container running redis in the background - skip this
$ # if you already have redis running on localhost:6379 (connection information is in src/config.js)
$ npm run start:redis
$
$ # 2. Starts a process that runs a local web server on port 5000 - this can be horizontally scaled
$ npm start
$
$ # 3. Starts a process that listens for bullmq messages - this can be horizontally scaled
$ npm run start:worker

Now that you have everything running, you should see a * Periodic task executed! log in the worker process every 5 seconds.

To trigger the async task, run npm run trigger-event. This will make a request with curl to the local web server, which will put a message into redis with bullmq. Then, the worker process will pick up this message and process it, logging out something starting with * Triggered task executed!

About

Demo using bullmq in node.js to process periodic and async jobs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published