Registry / devops / moleculer-psql-queue

moleculer-psql-queue

JSON →
library0.3.0jsnpmunverified

Task queue mixin for Moleculer microservice framework, backed by graphile-worker running on PostgreSQL. Version 0.3.0 is current; the package follows a slow release cadence. It allows defining job handlers as queue properties and provides methods for job creation, with a configurable producer/consumer model. Main differentiator: tight integration with Moleculer's mixin system, automatic logging, and lifecycle management.

npm install moleculer-psql-queue
INSTALL
IMPORT
SIG · MOLECULER-PSQL-QUE
M
moleculer-psql-queue
devopsjavascriptv0.3.0
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.

PsqlQueueService
import PsqlQueueService from 'moleculer-psql-queue'
const { PsqlQueueService } = require('moleculer-psql-queue')
Default export is a function that returns the mixin object.
PsqlQueueService
const PsqlQueueService = require('moleculer-psql-queue')
import { PsqlQueueService } from 'moleculer-psql-queue'
CommonJS default require works; named import is incorrect.
PsqlQueueService (TypeScript)
import PsqlQueueService from 'moleculer-psql-queue'
Package has no typings; use @types/graphile-worker if needed.

Creates a Moleculer microservice with graphile-worker job queue mixin, defining two task handlers and configuring the database connection from environment variable.

const PsqlQueueService = require('moleculer-psql-queue'); const { ServiceBroker } = require('moleculer'); const broker = new ServiceBroker(); broker.createService({ name: 'task-worker', mixins: [ PsqlQueueService( process.env.DATABASE_URL ?? 'postgres://postgres:postgres@localhost:5442/task_queue', { schemaProperty: 'queues', createJobMethodName: 'createJob', producerPropertyName: '$producer', consumerPropertyName: '$consumer', internalQueueName: '$queue', jobEventHandlersSettingsProperty: 'jobEventHandlers', producerOpts: {}, queueOpts: { concurrency: 5, noHandleSignals: false, pollInterval: 1000, }, } ), ], queues: { 'sample.task'(payload, helpers) { this.logger.info('Received sample.task', payload); }, 'another.task': { process(payload, helpers) { this.logger.info('Processed another.task', payload); }, }, }, }); broker.start().then(() => broker.logger.info('Broker started'));
Debug
Known issues
gotchaMissing PostgreSQL schema initialization will cause runtime errors.
fix
Run `npx graphile-worker -c "<connection-string>" --schema-only` before starting the service.
affects: >=0.0.0
gotchaThe mixin function must be called (returns object), not used directly as a class.
fix
Wrap call: `mixins: [PsqlQueueService(connectionString, options)]`
affects: >=0.0.0
breakingNode.js >= 20 required; older versions throw import errors.
fix
Upgrade Node.js to v20+.
affects: >=0.3.0
gotchaThe package does not ship TypeScript definitions; developers must declare ambient module or use @types/graphile-worker.
fix
Create a .d.ts file with `declare module 'moleculer-psql-queue';`
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'moleculer-psql-queue'
Missing npm install or incorrect import path.
fix
Run `npm install moleculer-psql-queue` and verify the import statement.
TypeError: PsqlQueueService is not a function
Using named import (destructured) instead of default import.
fix
Use `const PsqlQueueService = require('moleculer-psql-queue')` or ES default import.
error: relation "graphile_worker.jobs" does not exist
Graphile Worker schema not initialized in PostgreSQL.
fix
Execute `npx graphile-worker -c "<connection>" --schema-only`
Upgrade
Version history
0.3.0latest on npm
Audit
Dependencies
moleculerrequiredPeer dependency: Moleculer microservice framework v0.12-0.15
Agent activity
4 hits · last 30 days
node
4
Resources
moleculer-psql-queue — npm install moleculer-psql-queue · libregistry