PgChannelListener
Manages PostgreSQL LISTEN/UNLISTEN subscriptions on a dedicated database connection.
Each instance holds a single dedicated connection that lives for the duration of the listener's lifecycle. Use close (or kotlin.io.use) to release the connection when done.
Typical usage:
db.createChannelListener().use { listener ->
listener.listen("orders", "notifications")
listener.notifications()
.collect { notification ->
println("Received on ${notification.channel}: ${notification.payload}")
}
}Content copied to clipboard
Functions
Link copied to clipboard
Subscribes to the given channels. Executes LISTEN for each channel.
Link copied to clipboard
Returns a cold Flow of PgNotification objects received on subscribed channels.
Link copied to clipboard
Unsubscribes from the given channels. Executes UNLISTEN for each channel.
Link copied to clipboard
Unsubscribes from all currently subscribed channels. Executes UNLISTEN *.