-
Notifications
You must be signed in to change notification settings - Fork 18
Assembly Java Play! Framework Web Application
#3 Design:
The application is a standard model-view-controllers design. The controllers package handles the incoming web requests and returns responses. 98% of the responses are JSON types.
In addition, there is also a websocket controller which will initiate a websocket connection. The websocket is designed to send and receive JSON payloads. When a request for a websocket controller is made, it is made with certain parameters to indicate what page the user might be viewing (default, region page, nation page, etc). Certain pages require specific payloads to be sent along the websocket request immediately after it is created. Otherwise, the client will send JSON requests through the websocket, and the server will either respond, or send an error payload back to the client.
Besides the MVC web application, there is also a number of background tasks that run at repeated interval in the background. These tasks are optional, and only the primary server should run them, or else there may be conflicting information inserted into the database or the NationStates API rate limit will be exceeded.
There is also a health watchdog thread that monitors the overall health of the web application. If the SQL connection pool loses a connection, background tasks fail unexpectedly for a repeated interval, or other catastrophe occurs, it attempts to gracefully stop the server, and restart. Due to the flaky nature of connections, unstable networks, and other unpredictable one-off problems, an error that might bring down a webserver occurs on a weekly basis. The health watchdog can stop and recover these sort of errors and can allow the web server to continue running for months at a time. Only extreme and very rare crashes (such as a JVM crash) that are unrecoverable can not be caught.