Spring R2DBC Prototype
Implements against PLSQL R2DBC connector with e.g. localhost
available DB service (see src/main/resources/r2dbc-demo.psql
for schema requirements).
Transactions can be inserted via REST POST with uniqueness criteria (period, sequence)
. These will be accumulated into aggregates, the latter having uniqueness criteria (period)
.
Play with:
- Spring Data transactionality,
- error handling (you can force such by e.g. additionally annotating
@Column("a_count")
with@NonNull
), - synchronisation and thread safety,
and see how reactive R2DBC operations behave under concurrency.
src/main/resources/application-secrets.yml
will need to be created locally, containing:
spring:
r2dbc:
username:
user
password:
pass
(make sure not to forget secrets as a Spring profile, e.g. mvn clean spring-boot:run -Dspring-boot.run.profiles=secrets
)
EPs exposed:
- GET http://localhost:8080/r2dbc-demo/aggregates,
- GET http://localhost:8080/r2dbc-demo/aggregates/{period},
- DELETE http://localhost:8080/r2dbc-demo/aggregates/{period},
- POST http://localhost:8080/r2dbc-demo/transactions/post,
latter accepting (JSON) payload such as,
{ "period": 0, "sequence": 0 }
Have a look at src/test/jmeter/r2dbc-demo_POST_transaction.jmx
for sample Apache JMeter test plan which can be run, e.g. env JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 jmeter -n -t r2dbc-demo_POST_transaction.jmx -l results.csv
(env JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 jmeter &
in UI).
Rudimentary tests (using R2DBC H2 mem DB) can be run, e.g. mvn clean test -Dspring.profiles.active=test
.
Prerequisites: Java 17, PostgreSQL server available somewhere.
Have fun :)