ClusteredRedisQueue class
Scales a single logical queue horizontally across several redis instances. This is what IMQ.create() returns when IMQOptions.cluster or IMQOptions.clusterManagers is supplied.
Signature:
export declare class ClusteredRedisQueue implements IMessageQueue, EventEmitter<EventMap>
Implements: IMessageQueue, EventEmitter<EventMap>
Remarks
Distribution is asymmetric, and this is the most important thing to know about the class: ClusteredRedisQueue.send() routes each message to exactly one server, chosen by health-aware round-robin that skips instances whose writer connection is not ready. Every other operation — start, stop, clear, destroy, publish, subscribe, unsubscribe and queueLength — fans out to every server.
Every fan-out uses Promise.all, so one failing host fails the whole call with no partial-failure reporting and no rollback.
The class only implements the EventEmitter interface rather than extending it, so instanceof EventEmitter is false and every emitter method is a delegating shim — see the individual methods for their fan-out semantics, and note in particular that ClusteredRedisQueue.once() is per-server.
Constructors
|
Constructor |
Modifiers |
Description |
|---|---|---|
|
Creates a clustered queue. |
Properties
|
Property |
Modifiers |
Type |
Description |
|---|---|---|---|
|
Logger used for this cluster's own messages, defaulting to IMQOptions.logger or | |||
|
string |
Name of this queue, used as the queue name for every per-host queue in the cluster. |
Methods
|
Method |
Modifiers |
Description |
|---|---|---|
|
Registers a listener on every server's queue and on the internal template. Alias of ClusteredRedisQueue.on(). | ||
|
|
Adds a single server to the cluster and returns its registration record. | |
|
Deletes this queue's data on every redis host in the cluster, concurrently. | ||
|
Destroys every server's queue — closing their connections and removing their event listeners — then unregisters this cluster from all configured cluster managers. | ||
|
Emits an event on every server's queue and on the internal template, so each listener registered through this class runs once per server. | ||
|
Returns the event names reported by a single representative emitter. | ||
|
Returns the maximum listener count of the internal template emitter. | ||
|
Returns the listener count reported by a single representative emitter. | ||
|
Returns the listeners of every server's queue plus the internal template, concatenated. | ||
|
Removes a listener from every server's queue and from the internal template. | ||
|
Registers a listener on every server's queue and on the internal template used to seed servers that join later. | ||
|
Registers a one-shot listener on every server's queue and on the internal template. | ||
|
Registers a listener at the front of the queue on every server's queue and on the internal template. | ||
|
Registers a one-shot listener at the front of the queue on every server's queue and on the internal template. | ||
|
Publishes the payload on every redis host in the cluster. | ||
|
Returns the total number of messages waiting, summed across every redis host in the cluster. | ||
|
Returns the raw listeners of every server's queue plus the internal template, concatenated. | ||
|
Removes every listener from every server's queue and from the internal template, so servers that join later also start clean. | ||
|
Removes a listener from every server's queue and from the internal template. Alias of ClusteredRedisQueue.off(). | ||
|
|
Removes a server from the cluster, matching by | |
|
Sends a message to one server of the cluster, selected by health-aware round-robin. | ||
|
Sets the maximum listener count on every server's queue and on the internal template. | ||
|
Starts every server's queue concurrently. | ||
|
Stops message handling on every server concurrently. | ||
|
Subscribes the given handler on every redis host in the cluster, and remembers the subscription so servers that join later are subscribed automatically. | ||
|
Unsubscribes from the channel on every redis host and forgets the remembered subscription, so servers joining later are no longer subscribed automatically. |
Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.