sendTopic

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

Sends a message to all queues that match the routing key pattern.

Uses AMQP-style topic routing with wildcards:

  • The routing_key is matched against all patterns in the topic_bindings table

  • Messages are sent to ALL matching queues

  • The operation is atomic: either all matching queues receive the message or none do

Return

A Result containing the number of queues that received the message.

Parameters

routingKey

The routing key for the message (e.g., "logs.error", "app.user.created"). Must not contain wildcards (* or #).

message

The content of the message to be sent.

headers

Optional metadata to include with the message. Defaults to an empty map.

delay

The duration to delay the message delivery. Defaults to 0 seconds.


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

Sends a message to all queues that match the routing key pattern.

This is the context version that can be used within a transaction or query executor.

Return

A Result containing the number of queues that received the message.

Parameters

routingKey

The routing key for the message.

message

The content of the message to be sent.

headers

Optional metadata to include with the message.

delay

The duration to delay the message delivery.