ClusteredRedisQueue.subscribe() method

Subscribes the given handler on every redis host in the cluster, and remembers the subscription so servers that join later are subscribed automatically.

Signature:

subscribe(channel: string, handler: (data: JsonObject) => void): Promise<void>;

Parameters

Parameter

Type

Description

channel

string

channel name within the queue's prefix namespace

handler

(data: JsonObject) => void

invoked with the parsed payload of each published message

Returns:

Promise<void>

Exceptions

TypeError when a different channel name is supplied while a subscription is already open on the underlying queues

Remarks

Only one channel per instance is supported. Calling this again with the same channel registers the handler a second time; calling it with a different channel rejects — and the remembered subscription is left pointing at the rejected name, which is what newly joining servers would then use.

The handler receives one invocation per host that delivers the message.

Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.