PostgreSQL Notify and Listen support using reactive spring boot
Last updated
Last updated
docker-compose up -d./mvnw clean package./mvnw spring-boot:runsequenceDiagram
participant Client
participant Application
participant Listener
participant PostgreSQL
Note over Application: Application starts
Application->>PostgreSQL: Connect to database
Application->>PostgreSQL: LISTEN channel_name
Note over Client: Trigger notification
Client->>Application: POST /api/notify
Application->>PostgreSQL: NOTIFY channel_name, 'message'
PostgreSQL-->>Listener: Notification event
Listener-->>Application: Process notification
Application-->>Client: Notification processed
Note over Client: Subscribe to events
Client->>Application: WebSocket connection
Application-->>Client: Stream notificationscurl -X POST http://localhost:8080/api/notify \
-H "Content-Type: application/json" \
-d '{"channel": "events", "message": "Hello World!"}'# R2DBC PostgreSQL Configuration
spring.r2dbc.url=r2dbc:postgresql://localhost:5432/postgres
spring.r2dbc.username=postgres
spring.r2dbc.password=postgres
# Notification Channel Configuration
app.notification.channel=events