Skip to content

Notify Adapters

Notify adapters handle pub/sub notifications for efficient job scheduling. When a job is created, workers are notified immediately instead of polling. This reduces latency from seconds to milliseconds.

Package: @queuert/redis

Recommended for production. Uses Redis pub/sub for broadcasting job notifications to workers. Includes a hint-based optimization using Lua scripts for atomic decrement, preventing thundering herd when many workers are idle — only as many workers as there are new jobs will query the database.

Terminal window
npm install @queuert/redis
ClientExample
node-redisnotify-redis-redis
ioredisnotify-redis-ioredis

Package: @queuert/nats

Experimental. Uses NATS pub/sub for job notifications. When JetStream KV is available, supports revision-based CAS operations for hint-based optimization.

Terminal window
npm install @queuert/nats
ClientExample
natsnotify-nats-nats

Package: @queuert/postgres

Uses PostgreSQL’s built-in LISTEN/NOTIFY mechanism. No additional infrastructure beyond your existing PostgreSQL database. All listeners query the database on notification (no hint-based optimization).

Terminal window
npm install @queuert/postgres
DriverExample
pgnotify-postgres-pg
postgres.jsnotify-postgres-postgres-js

The default when no notify adapter is configured. Workers poll the database on a configurable interval to check for new jobs. No additional packages or infrastructure required. Suitable for low-throughput workloads where millisecond latency is not critical.

A Notify Provider bridges your pub/sub client (Redis, NATS, PostgreSQL, etc.) with the notify adapter. You implement an interface for publishing messages and subscribing to channels:

  • publish — Sends a message to a named channel.
  • subscribe — Listens on a channel and invokes a callback when messages arrive. Returns a dispose function to unsubscribe.

The provider maintains a dedicated connection for subscriptions and acquires/releases connections for publish operations automatically. Each example linked above demonstrates a complete Notify Provider implementation for its corresponding client.