send

suspend fun send(queue: String, message: String, headers: Map<String, String> = emptyMap(), delay: Duration = 0.seconds): Result<Long>(source)

Sends a message to the specified queue with optional headers and delay.

The message can include additional metadata in the form of headers, and its delivery can be delayed by the specified duration. This method returns the unique identifier of the enqueued message upon successful delivery.

Return

A Result containing the unique ID of the enqueued message if the operation is successful. Otherwise, it contains an error indicating the failure reason.

Parameters

queue

The name of the queue to which the message should be sent.

message

The content of the message to be sent to the queue.

headers

Optional metadata to include with the message, represented as a map of key-value pairs.

delay

The duration to delay the message delivery, with a default value of 0 seconds.


context(db: QueryExecutor)
suspend fun send(queue: String, message: String, headers: Map<String, String> = emptyMap(), delay: Duration = 0.seconds): Result<Long>(source)

Sends a message to the specified queue with optional headers and delay.

This method enqueues a message into the designated queue, optionally including metadata (headers) and specifying a delay before the message becomes available for processing. The method returns the unique ID of the message upon successful delivery.

Return

A Result containing the unique identifier of the enqueued message on success, or an error if the operation fails.

Parameters

queue

The name of the queue where the message should be sent.

message

The actual content of the message to be sent to the queue.

headers

Optional metadata associated with the message, represented as a map of key-value pairs. Defaults to an empty map.

delay

The delay before the message becomes available, specified as a duration. Defaults to 0 seconds.


suspend fun send(queue: String, messages: List<String>, headers: Map<String, String> = emptyMap(), delay: Duration = 0.seconds): Result<List<Long>>(source)

Sends multiple messages to the specified queue with optional headers and delay.

This method enqueues a batch of messages into the designated queue, optionally including metadata (headers) and specifying a delay before the messages become available for processing. Each message in the batch will be associated with a unique ID upon successful delivery.

Return

A Result containing a list of unique identifiers (IDs) for the enqueued messages on success, or an error if the operation fails.

Parameters

queue

The name of the queue where the messages should be sent.

messages

A list of message contents that should be sent to the queue.

headers

Optional metadata to associate with the messages, represented as a map of key-value pairs. Defaults to an empty map.

delay

The duration to delay the messages before they become available, specified as a Duration. Defaults to 0 seconds.


context(db: QueryExecutor)
suspend fun send(queue: String, messages: List<String>, headers: Map<String, String> = emptyMap(), delay: Duration = 0.seconds): Result<List<Long>>(source)

Sends a batch of messages to the specified queue with optional headers and a delay.

Return

A Result containing a list of message IDs that were successfully sent.

Parameters

queue

The name of the queue to which the messages should be sent.

messages

A list of messages to send to the queue.

headers

An optional map of headers to include for the messages. Defaults to an empty map.

delay

An optional delay duration before messages are sent. Defaults to 0 seconds.