This sample project serves as a starting point to try the various features of spring webflux.
- Import in IntelliJ & run WebfluxSampleMainApplication
- test REST Api using browser
- run parallel REST calls using
node node-client/client.js
- observe spring logs in IntelliJ
You can use a simple local external system by running
node ./external-system/server.js
It exposes a delayed REST Api under http://localhost:3000/200?sleep=3000 where you can specify how long the sleep time should by with the "sleep" GET Param
Be aware that certain REST endpoints call https://httpstat.us as a external system.
If you are producing many requests during your tests, e.g. using a load testing tool like Gatling, please use a local external system or a service which specifically allows such load testing.
- Run Backend in IntelliJ
- Open browser, visit “http://localhost:8080/api/sample/hello” and “http://localhost:8080/api/sample/stream”
- Observe spring boot logs (request and onNext)
- Basics of the Java 9 Flow API: https://www.hascode.com/2018/01/reactive-streams-java-9-flow-api-rxjava-and-reactor-examples/#Reactor
- Run local external system. The system simulates a delay given as GET Param.
-
node ./external-system/server.js
- Open browser, visit “http://localhost:8080/api/external-system/local”
- Observe spring boot logs and also nodejs logs
-
- Execute multiple concurrent requests against the spring boot backend
-
-> this will execute a small load test with concurrent requests for the external system use case
Node ./node-client/client.js
- Observe the spring boot logs and notice how the same threads (about 8) handle all the requests and then defer the response. The response is handled reactively (async) by the same 8 threads.
-
- Check out Webflux testing (example provided in "FluxCombinationUseCaseTest")
- Implement Socket.io interface between Angular Client and Spring Backend
- Implement Websocket External System, pipe Websocket messages from external system right to the client
- Learn about Backpressure and what happens if the external system floods our backend with Websocket messages
- Try out RSocket & different Backpressure scenarios
- Integrate a reactive DB (mongo or postgres)