IMessageQueue.publish() method
Publishes data to the current queue channel
If toName is specified, publishes to a pubsub with a different name. This can be used to broadcast messages to other subscribers on different pubsub channels. Different names must be in the same namespace (same imq prefix).
Signature:
publish(data: JsonObject, toName?: string): Promise<void>;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
data |
data to publish as a channel message | |
|
toName |
string |
(Optional) optional different pubsub name to publish to |
Returns:
Promise<void>
Exceptions
TypeError when the queue has no writer connection
Remarks
Unlike IMessageQueue.send(), this does not start the queue implicitly — IMessageQueue.start() must have completed first. The payload is always plain JSON (IMQOptions.useGzip does not apply), and pub/sub delivery is not persisted, so subscribers that are not connected at publish time never receive the message.
Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.