Skip to main content

Named workstreams

Named workstreams isolate certain work within a dedicated BullMQ Queue. Not only does this enable control over resource allocation to certain work, but it organizes visualization when using a dashboard such as the Taskforce BullMQ dashboard or the open source Bull Board (available for Koa, Express, and other frameworks):

Bull Board Integration

Bull Board provides monitoring dashboards for BullMQ. For Psychic 3.0 (Koa-based), use @bull-board/koa. If you're using Psychic 2.0 (Express-based), use @bull-board/express.

Bull Dashboard

Configure named workstreams in conf/workers.ts by adding a namedWorkstreams key:

  workersApp.set('background', {
...

namedWorkstreams: [
{
name: 'Iterable',
// https://docs.bullmq.io/guide/parallelism-and-concurrency
workerCount: 1,
concurrency: 10,
},
{
name: 'Twilio',
// https://docs.bullmq.io/guide/parallelism-and-concurrency
workerCount: 1,
concurrency: 10,
},
],
})

...
})

Then set the workstream used by the class:

class IntercomSync extends ApplicationBackgroundedService {
public static get backgroundJobConfig(): BackgroundJobConfig<ApplicationBackgroundedService> {
return { workstream: 'Iterable' }
}
}