Chat application built with Spring WebFlux
- Java 17
- MongoDB 3.6+
This project uses Gradle Wrapper and the Gradle Kotlin DSL.
To build the project use:
gradlew clean build
To run the application you can use one of the tasks provided by the Spring Boot Gradle Plugin:
gradlew bootRun
Additionally, you can also set specific application profiles, e.g. for dev
use:
gradlew bootRun --args='--spring.profiles.active=dev'
The project makes use of MongoDB Change Streams to stream new chats and chat messages via Server-Sent Events (SSE) endpoints based on the text/event-stream
media type.
Change Stream support is only possible for replica sets or for a sharded cluster.
Running a standalone MongoDB instance and calling the aforementioned endpoint will result in an exception:
com.mongodb.MongoCommandException: Command failed with error 40573 (Location40573): 'The $changeStream stage is only supported on replica sets' on server localhost:27017.
Please refer to this tutorial to deploy a replica set.
Feel free to use the included Docker Compose file to get started locally.