PgMqClient
PgMqClient is a client for interfacing with the pgmq system, providing various messaging queue operations. This client makes use of PostgreSQL as a message queue backend.
Parameters
The PgMqDbAdapter instance used for executing database queries.
Configuration options for the client, including installation verification and auto-install behavior.
Features:
Installation verification of the pgmq extension in the database.
Creating and managing queues with optional notification on message insertion.
Listing all existing queues.
Sending messages to a queue, with support for headers and optional delay.
Batch sending of messages to a queue.
Popping messages from a queue.
Reading messages from a queue with optional visibility timeout.
Archiving and deleting messages by single or bulk identifiers.
Purging all messages from a queue.
Functions
Archives an item identified by its ID from a specified queue.
Archives the specified items identified by their IDs from the given queue.
Archives a message in the specified queue by calling the pgmq.archive function.
Archives messages identified by their IDs from a specified queue.
Creates a topic binding between a pattern and a queue.
Creates topic bindings for multiple patterns to a single queue.
Creates a queue in the system with the specified configuration.
Deletes an item with the specified ID from the given queue.
Deletes the specified items from the given queue.
Deletes a message from the specified queue based on its unique identifier.
Deletes messages from the specified queue based on the provided list of IDs.
Drops the specified queue from the system.
Retrieves the list of all available queues in the system.
Removes all messages from the specified queue.
Reads messages from a specified queue.
suspend fun read(queue: String, quantity: Int = 1, vt: Duration = 30.seconds): Result<List<Message>>
Reads messages from a specified queue with the given parameters.
suspend fun send(queue: String, message: String, headers: Map<String, String> = emptyMap(), delay: Duration = 0.seconds): Result<Long>
Sends a message to the specified queue with optional headers and delay.
Sends multiple messages to the specified queue with optional headers and delay.
suspend fun send(queue: String, messages: List<String>, headers: Map<String, String> = emptyMap(), delay: Duration = 0.seconds): Result<List<Long>>
Sends a batch of messages to the specified queue with optional headers and a delay.
suspend fun sendTopic(routingKey: String, message: String, headers: Map<String, String> = emptyMap(), delay: Duration = 0.seconds): Result<Long>
Sends a message to all queues that match the routing key pattern.
Updates the visibility timeout (VT) for a specific item in the given queue.
Updates the visibility timeout (VT) for a message in the specified queue.
Removes a topic binding between a pattern and a queue.