Registry / devops / egg-bull-queue

egg-bull-queue

JSON →
library1.2.1jsnpmunverified

Egg.js plugin integrating Bull Redis-backed job queue. Version 1.2.1 enables Egg applications to define and process background jobs using Bull's fast, reliable queue. Requires Egg.js and Redis; supports single or multiple queue configurations. Differentiator: seamless integration with Egg.js lifecycle, automatic worker process management, and TypeScript types via @types/bull.

npm install egg-bull-queue
INSTALL
IMPORT
SIG · EGG-BULL-QUEUE
E
egg-bull-queue
devopsjavascriptv1.2.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

app.bull
Access app.bull after enabling plugin in config/plugin.js and configuring in config/config.default.js.
const bull = require('bull');
Plugin registers bull on app; do not require bull directly for basic usage.
plugin exports
// config/plugin.js exports.bull = { enable: true, package: 'egg-bull-queue' };
exports.bullQueue = { enable: true, package: 'egg-bull-queue' };
Plugin name must be 'bull' exactly to match configuration keys.
config clients
// config/config.default.js exports.bull = { clients: { q1: { name: 'q1' } }, default: { redis: { host: 'localhost' } } };
exports.bull = { clients: { q1: { name: 'q1', redis: { host: 'localhost' } } } };
The 'default' key holds default Redis config; individual client redis config overrides default.

Shows Egg.js configuration to enable bull plugin, define a single queue client, add a job from controller, and auto-process jobs.

// config/plugin.js exports.bull = { enable: true, package: 'egg-bull-queue', }; // config/config.default.js exports.bull = { client: { name: 'myqueue', redis: { host: 'localhost', port: 6379, db: 0, }, }, }; // app/controller/home.js class HomeController extends require('egg').Controller { async index() { const job = await this.app.bull.add({ data: 'hello' }); this.ctx.body = `Job added: ${job.id}`; } } // app/queue/myqueue.js (auto-process) module.exports = app => { app.bull.process(async job => { console.log('Process job', job.id, job.data); return done(); }); };
Debug
Known issues
gotchaPlugin name must be 'bull' exactly in config/plugin.js; any other name will not register app.bull.
fix
Use exports.bull = { enable: true, package: 'egg-bull-queue' };
affects: >=1.0.0
gotchaMultiple queue config requires 'default' key for shared Redis options; per-queue redis overrides default.
fix
Set default: { redis: { host: 'localhost', port: 6379 } } in config if using clients.
affects: >=1.0.0
gotchaQueue processors must be defined in app/queue/<queueName>.js, exporting a function that receives app; otherwise jobs stay pending.
fix
Create file app/queue/<name>.js with module.exports = app => { app.bull.process(job => { /* */ }); };
affects: >=1.0.0
gotchaDo not call require('bull') directly; the plugin manages Bull instances.
fix
Use app.bull throughout your Egg app.
affects: >=1.0.0
deprecatedProcess callback style (done) is deprecated in Bull v4; promise-based return is recommended.
fix
Return a Promise from process handler instead of calling done().
affects: >=1.2.0
Errors
Common errors & fixes
Error: Cannot find module 'egg-bull-queue'
Package not installed or not present in node_modules.
fix
Run 'npm install egg-bull-queue --save' in your project root.
ReferenceError: app is not defined
Using app.bull outside of Egg.js context (e.g., in a plain Node script).
fix
Access app.bull only inside Egg.js controllers, services, or lifecycle hooks.
TypeError: Cannot read property 'add' of undefined
app.bull is undefined because plugin not enabled or configured correctly.
fix
Ensure config/plugin.js has exports.bull = { enable: true, package: 'egg-bull-queue' } and config/config.default.js has exports.bull.client = { ... }.
Error: Queue name is required
Missing 'name' property in queue configuration.
fix
Add name: 'your-queue-name' to client config or each clients entry.
Upgrade
Version history
1.2.1latest on npm
Audit
Dependencies
bullrequiredCore queue library; egg-bull-queue wraps Bull.
Agent activity
4 hits · last 30 days
node
4
Resources
egg-bull-queue — npm install egg-bull-queue · libregistry