Registry / devops / moleculer-bull

moleculer-bull

JSON →
library0.3.1jsnpmunverified

Task queue mixin for Bull, integrating Redis-backed job queues into Moleculer microservices. Version 0.3.1 is the latest stable release, requiring Node >= 12 and Moleculer ^0.14.0 || ^0.13.0 || ^0.12.0. It allows creating queue workers and job producers using Bull with Moleculer service mixins, supporting named jobs, concurrency, and progress tracking. Unlike direct Bull usage, it leverages Moleculer's service lifecycle and logging. Release cadence is sporadic; no major updates since 2021.

npm install moleculer-bull
INSTALL
IMPORT
SIG · MOLECULER-BULL
M
moleculer-bull
devopsjavascriptv0.3.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.

QueueService
const QueueService = require('moleculer-bull');
const { QueueService } = require('moleculer-bull');
CJS default export. Named export does not exist.
QueueService
import QueueService from 'moleculer-bull';
import { QueueService } from 'moleculer-bull';
ESM default import works in Node >=12. Named import is incorrect.
createJob / getQueue
this.createJob('queueName', payload); this.getQueue('queueName');
this.jobs.createJob('queueName', payload);
Methods mix into the service instance directly.

Shows how to create queue worker and job producer services using moleculer-bull mixin.

const QueueService = require('moleculer-bull'); const { ServiceBroker } = require('moleculer'); const broker = new ServiceBroker(); // Create queue worker service broker.createService({ name: 'task-worker', mixins: [QueueService('redis://localhost:6379')], queues: { 'mail.send'(job) { this.logger.info('Received job', job.data); job.progress(50); return Promise.resolve({ done: true, id: job.data.id }); } } }); // Create job producer service broker.createService({ name: 'job-maker', mixins: [QueueService()], methods: { sendEmail(payload) { this.createJob('mail.send', payload); } } }); broker.start().then(() => broker.call('job-maker.sendEmail', { to: 'test@test.com' }));
Debug
Known issues
gotchaThe QueueService factory function MUST be called when passed to mixins, even without arguments.
fix
Use mixins: [QueueService()] NOT mixins: [QueueService]
affects: >=0.0.0
breakingIn version 0.3.0, the signature of QueueService changed from accepting a string URL to accepting an object with 'redis' property.
fix
For version 0.3.0+, pass an object: QueueService({ redis: 'redis://...' })
affects: >=0.3.0
deprecatedUsing `this.Promise` is deprecated. Use native Promise instead.
fix
return Promise.resolve(...) instead of return this.Promise.resolve(...)
affects: >=0.2.0
gotchaWhen using named jobs, queue name and job name are separate. The queue name must be unique per service.
fix
Do not reuse the same queue name for different job names; they are scoped within one queue.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'moleculer-bull'
Package not installed or wrong import path.
fix
Run `npm install moleculer-bull` and use correct require path.
TypeError: QueueService is not a function
QueueService was not called as a function.
fix
Use mixins: [QueueService()] with parentheses.
TypeError: Cannot read property 'createService' of undefined
broker is not defined or not instantiated.
fix
Ensure you create a ServiceBroker instance: const broker = new ServiceBroker();
Error: Redis connection to 127.0.0.1:6379 failed
Redis server not running or wrong host/port.
fix
Start Redis or specify correct URL: QueueService('redis://your-host:port')
Upgrade
Version history
0.3.1latest on npm
Audit
Dependencies
moleculerrequiredPeer dependency for Moleculer framework integration
Agent activity
4 hits · last 30 days
node
4
Resources
moleculer-bull — npm install moleculer-bull · libregistry