Sample project for a Game Rental application as a showcase for Axon
The "Game Rental" application showcases how Axon Framework and Axon Server or AxonIQ Cloud can be used during software development. The domain focused on is that of rental services from the perspective of a video game store.
This repository provides just such an application, albeit a demo rather than a full-fledged solution. It serves the personal purpose of having a stepping stone application to live code during presentations. I intend to build upon this sample during consecutive talks, further enhancing its capabilities as time progresses.
For others, I hope this provides a quick and straightforward look into what it means to build an Axon-based application.
Due to its nature of being based on Axon, it incorporates DDD, CQRS, Event Sourcing, and an overall message-driven solution to communicate between distinct components.
Demo Recordings with different Game Rental implementations
Since I aim to use this project for some time, it'll change through its lifecycle. Most notably, I'll keep it up to date with recent versions of the dependencies.
Due to this, recordings from previous iterations of this project will likely show slight deviations. However, the taken steps during those recordings will remain intact.
Distinct branches will be (made) available per public speaking, sharing a start and final solution branch separately. Additionally, several branches representing the steps throughout the lifecycle of the "Game Rental" application will be present, allowing you to:
git reset --hard step#
to reset your current branch.Next to providing the convenience of showing the flow, it also serves as a backup during the presentation.
This project currently contains the following steps:
core-api
, containing the commands, events, queries, and query responses.command
model has been created, showing a Game
aggregate.application.properties
.query
model, a GameView
, is provided, created/updated, and made queryable through the GameCatalogProjector
.GameRentalController
.@ExceptionHandler
annotated functions in the Game
aggregate and GameCatalogProjector
, containing an ExceptionStatusCode
.@Profile{{profile-name})
annotation has been added to the Game
, GameCatalogProjector
, GameViewRepository
and GameRentalController
, allowing for application distribution.GameRentalRSocketController
, providing an entry point to the application using RSocket.ReservationService
once a game is returned. Since this service only has a flunky implementation, attach a dead-letter queue to the reservations
processing group to deal with errors.As this is a Spring Boot application, simply running the GameRentalApplication
is sufficient.
However, Spring profiles are present, which allow for running portions of this application.
More specifically, there's a command
, query
, ui
, rsocket
, and reservations
profile present, thus separating the Game
aggregate, GameCatalogProjector
, GameRentalRestController
, GameRentalRSocketController
, and reservation specifics components into distinct groups.
Furthermore, when you use IntelliJ, you can use the "Run Configurations" from the ./.run
to speed up the startup process.
The application does expect it can make a connection with an Axon Server instance. Ideally, Axon Cloud is used for this, as is shown in step 3. If you desire to run Axon Server locally, you can download it here.
Unit Tests
Any new components introduced in a step include unit tests. These can be used to better understand the project.
For validating the application's internals, you can run the tests, use the REST endpoint, or connect with the RSocket endpoint.
When testing through the REST endpoint, IntelliJ Ultimate you can use the included .http
files (in the http-requests
folder of this project).
The 1-register-games.http
allows for the registration of several games to build a base catalog.
The 2-rent-return-find.http
file contains rent, return, and find operations for testing.
The 3-bulk-rent-return.http
file contains a bulk of rent and return operations for a single game to test bulk.
The 4-dead-letter-management.http
file contains the endpoint to process dead-letters.
When testing through RSocket, the most straightforward approach is to install the RSocket Client CLI, or rsc
for short.
The README of rsc
provides concrete explanations on how to install it in your environment.
With rsc
in place, you can use the following commands to test the application:
rsc --debug --request --route register --data="{\"gameIdentifier\":\"8668\",\"title\":\"Hades\",\"releaseDate\":\"2020-09-17T00:00:01.000009Z\",\"description\":\"Roguelike dungeon crawler set in ancient Greek mythology\",\"singleplayer\":true,\"multiplayer\":false}" tcp://localhost:7000
rsc --debug --fnf --route rent --data="{\"gameIdentifier\":\"8668\",\"renter\":\"Ben Wilcock\"}" tcp://localhost:7000
rsc --debug --fnf --route return --data="{\"gameIdentifier\":\"8668\",\"renter\":\"Ben Wilcock\"}" tcp://localhost:7000
rsc --debug --request --route find --data="8668" tcp://localhost:7000
rsc --debug --stream --route catalog tcp://localhost:7000
The steps this project traverses show a common approach towards constructing an Axon application. If you want to begin from scratch, consider these key aspects: