Skip to content

Commit efaacba

Browse files
committed
Add LISTEN/NOTIFY to README
1 parent ef0bee8 commit efaacba

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.markdown

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
- [Prepared statements](#prepared-statements)
1818
- [Transactions](#transactions)
1919
- [Example usage (for PostgreSQL, but it looks almost the same on MySQL)](#example-usage-for-postgresql-but-it-looks-almost-the-same-on-mysql)
20+
- [LISTEN/NOTIFY support (PostgreSQL only)](#listennotify-support-postgresql-only)
2021
- [Contributing](#contributing)
2122
- [Licence](#licence)
2223

@@ -269,6 +270,21 @@ disconnect and the connection is closed.
269270
You can also use the `ConnectionPool` provided by the driver to simplify working with database connections in your app.
270271
Check the blog post above for more details and the project's ScalaDocs.
271272

273+
## LISTEN/NOTIFY support (PostgreSQL only)
274+
275+
LISTEN/NOTIFY is a PostgreSQL-specific feature for database-wide publish-subscribe scenarios. You can listen to database
276+
notifications as such:
277+
278+
```scala
279+
val connection: Connection = ...
280+
281+
connection.sendQuery("LISTEN my_channel")
282+
connection.registerNotifyListener {
283+
message =>
284+
println(s"channel: ${message.channel}, payload: ${message.payload}")
285+
}
286+
```
287+
272288
## Contributing
273289

274290
Contributing to the project is simple, fork it on Github, hack on what you're insterested in seeing done or at the

0 commit comments

Comments
 (0)