Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rburgst/sse-jpa-demo

a demo repository showing problems with JPA and SSE
https://github.com/rburgst/sse-jpa-demo

Last synced: 2 days ago
JSON representation

a demo repository showing problems with JPA and SSE

Awesome Lists containing this project

README

        

## Sample repository showing a problem with JPA and SSE.

### How To

1. Launch the app

```
./gradlew bootRun
```

2. Launch the browser with http://localhost:8080

3. Open a 2nd window with http://localhost:8080/metrics and keep an eye on `datasource.primary.active`

4. On the 1st browser window press Submit a couple of times, this will cause a page reload and should cause connections
to get leaked

The main problem seems to be `org.springframework.orm.jpa.support.OpenEntityManagerInViewInterceptor` which keeps the
JDBC connection open until the SSE socket throws an exception. If we dont try to send any SSEs for a long time
then the connection pool will run out of connections before the first SSE emitter throws an exception and only then gets
cleaned up.

This repository serves as an example for https://github.com/spring-projects/spring-boot/issues/12110.