This project is an implementation of the Game server on top of Vert.x.
It provides the HTTP endpoints and websockets for the game part of the demo.
The projects is composed by 3 verticles:
MainVerticle
just deploys the 2 other verticlesServerVerticle
creates a HTTP server and manage HTTP requests and web sockets, data is computed by theGameVerticle
GameVerticle
manages the game. It is written in Groovy
This architecture lets us increase the number of instances of the GameVerticle
to face the load. The ServerVerticle
and GameVerticle
are communicating using the event bus. So, potentially, the GameVerticle
instances can be located on different computers.
mvn clean package -DskipTests
It generates a fat jar in target
: game-service-1.0.0-SNAPSHOT-fat.jar
Launch it with: java -jar target/game-service-1.0.0-SNAPSHOT-fat.jar - cluster
Tests are simulating a couple of loads, so may takes a bit of time to run.
mvn compile exec:exec@run
vertx run src/main/java/com/redhat/middleware/keynote/MainVerticle.java -cluster -cp target/game-service.jar --redeploy=src/main/**/* --launcher-class=io.vertx.core.Launcher --on-redeploy="mvn compile package -DskipTests"
You can pass a configuration object using: -conf my-configuration.json
.
This configuration can contain:
game-verticle-instances
: the number ofGameVerticle
instances, 1 by default, can be 0server-verticle-instances
: the number ofServerVerticle
instances, 4 by default, can be 0port
: the HTTP server port,9001
by defaultnumber-of-teams
: the number of teams, 4 by defaultscore-broadcast-interval
: the period in ms between 2 score broadcast, 2500 by default
export ACHIEVEMENTS_SERVER=localhost export ACHIEVEMENTS_SERVER_PORT=9090 export SCORE_SERVER=localhost export SCORE_SERVER_PORT=8080 export SCORE_USER=kiewb export SCORE_PASSWORD=kiewb