/webflux-demo

A demo project for Spring Webflux

Primary LanguageJavaApache License 2.0Apache-2.0

Webflux demo: SensorData

en de

Demo project with Spring Webflux, MongoDB and Node.js Publisher

Repository branches

Branches in the repository show different implementation variants:

  • main: Webflux backend + Server-Sent Events (SSE) + Thymeleaf client
  • websockets-based-implementation: Webflux backend + Websockets + Thymeleaf client
  • graphql-api-with-subscription: Webflux backend + Subscription via GraphQL-API
  • vue-frontend: Webflux backend + Server-Sent Events (SSE) + Vue.js client

Install and start MongoDB

Mock sensors

Start the node script mockSensor/index.js → the script continuously fills the database with "sensor data" until it is terminated

Webflux backend

The backend works with Spring Webflux, Netty and Thymeleaf. It can be started via the class /webflux-demo/src/main/java/en/fhdo/webfluxdemo/SensorDataApp.java or via mvn spring-boot:run.

Start and test

  • Start mock sensor and Webflux backend
  • Test server-side rendered view: http://localhost:8080/sensor/list
  • Test REST-API: curl -H "Accept: text/event-stream" http://localhost:8080/sensor/api/temperature

Clean up MongoDB

No data records can be deleted from capped collections, so the collection must be dropped and recreated!