File tree Expand file tree Collapse file tree 1 file changed +39
-2
lines changed
Expand file tree Collapse file tree 1 file changed +39
-2
lines changed Original file line number Diff line number Diff line change @@ -26,11 +26,48 @@ Uses PostgreSQL `LISTEN / NOTIFY` built-in [asynchronous notifications](https://
2626The library is available on maven central.
2727
2828#### Gradle
29- ` implementation("io.github.aleh-zhloba:postgresql-messaging:0.5.0") `
29+ ``` kotlin
30+ implementation(" io.github.aleh-zhloba:postgresql-messaging:0.5.0" )
31+ ```
32+ #### Maven
33+ ``` xml
34+ <dependency >
35+ <groupId >io.github.aleh-zhloba</groupId >
36+ <artifactId >postgresql-messaging</artifactId >
37+ <version >0.5.0</version >
38+ </dependency >
39+ ```
3040
3141### Example of usage
3242
33- ### Spring
43+ The library comes with the auto-configuration class, so if you have configured JDBC ` DataSource ` or R2DBC ` ConnectionFactory ` no additional steps required.
44+
45+ Listen notification messages with handler method:
46+ ``` kotlin
47+ @PostgresMessageListener(value = [" channel1" , " channel2" ], skipLocal = true )
48+ fun handleNotification (notification : YourNotificationClass ) {
49+ // ...
50+ }
51+ ```
52+
53+ Sending notification messages using ` PostgresMessagingTemplate ` :
54+ ``` kotlin
55+ messagingTemplate.convertAndSend(" channel1" , YourNotificationClass ())
56+ ```
57+
58+ Reactive API:
59+ ``` kotlin
60+ val pubSub: PostgresPubSub = R2dbcPostgresPubSub (connectionFactory)
61+
62+ pubSub.subscribe(" channel1" , " channel2" )
63+ .map { notification ->
64+ // ...
65+ }
66+ .subscribe()
67+
68+ pubSub.publish(" channel1" , " payload" )
69+ .subscribe()
70+ ```
3471
3572## License
3673** postgresql-messaging** is released under version 2.0 of the [ Apache License] ( https://www.apache.org/licenses/LICENSE-2.0 ) .
You can’t perform that action at this time.
0 commit comments