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.
npm install @queuert/redisSupported clients
Section titled “Supported clients”| Client | Example |
|---|---|
| node-redis | notify-redis-redis |
| ioredis | notify-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.
npm install @queuert/nats| Client | Example |
|---|---|
| nats | notify-nats-nats |
PostgreSQL LISTEN/NOTIFY
Section titled “PostgreSQL LISTEN/NOTIFY”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).
npm install @queuert/postgresSupported drivers
Section titled “Supported drivers”| Driver | Example |
|---|---|
| pg | notify-postgres-pg |
| postgres.js | notify-postgres-postgres-js |
None (polling)
Section titled “None (polling)”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.
Notify Provider
Section titled “Notify Provider”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.
See Also
Section titled “See Also”- Adapter Architecture — NotifyAdapter design and broadcast semantics
- Horizontal Scaling — Multi-worker coordination via notifications