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 |
| node-redis cluster | notify-redis-cluster-node-redis |
| ioredis cluster | notify-redis-cluster-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 |
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 |
Built-in — no extra package. Imported from queuert.
Delivers job-arrival signals via in-memory subscriptions. Useful whenever publisher and subscriber run in the same process. Single-process only — workers in other processes won’t receive notifications.
import { createInProcessNotifyAdapter } from "queuert";
const notifyAdapter = await createInProcessNotifyAdapter();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.
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.
You’re not limited to the clients listed here — you can write a provider for any pub/sub client that supports the same semantics, or implement the NotifyAdapter interface from scratch for an entirely different message broker. See Custom Adapters for a walkthrough.
Verify your provider
Section titled “Verify your provider”Queuert ships a conformance runner that exercises the 18-case notify adapter suite against any provider you build. Embed it in a single test() block from your test framework to validate correctness:
import { runNotifyAdapterConformance } from "queuert/conformance";
test("my provider passes notify adapter conformance", async () => { await runNotifyAdapterConformance(async () => ({ notifyAdapter, dispose: async () => { /* close connections */ }, }));}, 60_000);Every example’s src/provider.spec.ts is a working template. See the Custom Adapters guide for a full walkthrough and the Conformance reference for the complete API.
See Also
Section titled “See Also”- Adapter Architecture — NotifyAdapter design and broadcast semantics
- Horizontal Scaling — Multi-worker coordination via notifications