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.
PgmqModule
✓ import { PgmqModule } from 'nestjs-pgmq'
✗ const { PgmqModule } = require('nestjs-pgmq')
ESM module; CommonJS require works but named import is preferred with TypeScript.
Processor
✓ import { Processor } from 'nestjs-pgmq'
✗ import { Processor } from '@nestjs/bull'
Mimics Bull decorators but from nestjs-pgmq package.
InjectQueue
✓ import { InjectQueue } from 'nestjs-pgmq'
✗ import { InjectQueue } from '@nestjs/bull'
Use InjectQueue from nestjs-pgmq; Bull's InjectQueue will not work.
Shows module registration, processor with @Processor/@Process, and queue injection with add method.
// app.module.ts
import { Module } from '@nestjs/common';
import { PgmqModule } from 'nestjs-pgmq';
@Module({
imports: [
PgmqModule.forRootAsync({
useFactory: () => ({
connectionString: 'postgres://postgres:postgres@localhost:5432/db',
}),
}),
PgmqModule.registerQueue({ name: 'notifications' }),
],
})
export class AppModule {}
// notifications.processor.ts
import { Processor, Process, PgmqJob } from 'nestjs-pgmq';
@Processor('notifications')
export class NotificationsProcessor {
@Process('send-email')
async handleEmail(job: PgmqJob<{ email: string; body: string }>) {
console.log(`Sending email to ${job.data.email}...`);
}
}
// users.service.ts
import { Injectable } from '@nestjs/common';
import { InjectQueue, PgmqQueue } from 'nestjs-pgmq';
@Injectable()
export class UsersService {
constructor(@InjectQueue('notifications') private readonly queue: PgmqQueue) {}
async registerUser(email: string) {
await this.queue.add('send-email', { email, body: 'Welcome!' });
}
}
Errors
Common errors & fixes
Cannot find module 'nestjs-pgmq'
Package not installed or dependency tree broken.
fixRun npm install nestjs-pgmq pg
ERROR [ExceptionHandler] connectionString is required
Missing or undefined connectionString in PgmqModule.forRootAsync.
fixEnsure the useFactory returns an object with connectionString property.
ERROR [ExceptionHandler] Queue 'notifications' not registered
PgmqModule.registerQueue not called with the queue name.
fixAdd PgmqModule.registerQueue({ name: 'notifications' }) to your module imports. Audit
Dependencies
pgrequiredPeer dependency for PostgreSQL client. Required to connect to the database.