Simple project for work with Websocket: spring-boot
, jetty-embedded
- Build system
- Alternatives: Maven, Gradle, ANT, SBT
- Selected: Gradle
- Reason: Gradle is declarative build system for Java project (same as Maven), that designed to build not only Java projects, and have many possibilities for change behavior of build process
- Embedded servlet container
- Alternatives: Tomcat embedded, Jetty
- Selected: Jetty
- Reason: Jetty has less footprint (~ 1.4 MiB, ~ 1.7 MiB with websocket implementation) than Tomcat (~ 2.7 MiB, 2.9 MiB with websocket implementation)
- WebSocket connection mode: in test client (JavaScript) and server simultaneously implemented two modes (pure websocket connection, and Sock.JS+STOMP)
- Pure websocket:
- Advantages:
- direct use WebSocket object in JavaScript
- no additional overhead
- Disadvantages:
- sometime could not work (e.g. CloudFlare)
- Advantages:
- Sock.JS+STOMP
- Advantages:
- work even browser does not support WebSocket or connection to WebSocket server is blocked
- supported by Spring
- Disadvantages:
- add overhead with STOMP protocol
- require additional library for interact with server
- Advantages:
- Pure websocket:
- Run project from console:
./gradlew bootRun
- Build executable jar:
./gradlew build
- Build test coverage report:
./gradlew check jacocoTestReport
and openbuild/reports/jacoco/test/html/index.html
- Run project in WildFly 10.0.0:
./gradlew build cargoRunLocal
- Sometimes WildFly could not access to temp file on VFS and fail deploy, in this case you need to stop WildFly and run command second time
- Sometimes
cargo
could not stop launched application server, in this case you can try stop server by command./gradlew cargoStopLocal
or killjava
manual