IMessageQueue.send() method
Sends a message to the specified queue with the given data.
Signature:
send(toQueue: string, message: JsonObject, delay?: number, errorHandler?: (err: Error) => void): Promise<string>;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
toQueue |
string |
name of the destination queue |
|
message |
message data to send | |
|
delay |
number |
(Optional) if specified, the message becomes available in the target queue only after this many milliseconds. This is a minimum, not a schedule: the message is released by the watcher, either on a Redis expired-key notification or on the next IMQOptions.watcherCheckDelay poll, so availability may lag by up to that interval. A delay of |
|
errorHandler |
(err: Error) => void |
(Optional) callback invoked only when an internal error occurs during message send execution |
Returns:
Promise<string>
the identifier assigned to the message
Exceptions
TypeError when the queue is in IMQMode.WORKER-only mode, or when a writer connection cannot be established
Remarks
The returned promise resolves as soon as the write has been dispatched — before the queue host confirms it, and long before the message is consumed. The identifier is generated locally, so it is available even if the write later fails. A resolved promise is therefore not evidence that the message was enqueued: supply errorHandler to observe write failures, which never reject.
Starts the queue implicitly when it has not been started yet. Delivery is at-least-once, so handlers must be idempotent.
Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.