RedisQueue.publish() method
Publishes a message to this queue subscription channel for currently subscribed clients.
If toName specified will publish to PubSub with a different name. This can be used to implement broadcasting some messages to other subscribers on other PubSub channels.
Signature:
publish(data: JsonObject, toName?: string): Promise<void>;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
data |
payload to publish as a channel message | |
|
toName |
string |
(Optional) optional different pub/sub name to publish to; must be a bare name inside the same prefix namespace, not a full Redis channel key |
Returns:
Promise<void>
Exceptions
TypeError when the queue has no writer connection
Remarks
Unlike RedisQueue.send(), this does not start the queue implicitly, so RedisQueue.start() must have completed first. It is allowed in any IMQMode, including WORKER.
The payload is always plain JSON — IMQOptions.useGzip applies to queue messages only. Redis pub/sub drops the message silently when nobody is subscribed.
Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.