Trading-Service
The Trading Service is responsible for processing intents from players that want to buy vouchers and crediting players for ingame actions.
| Artifacts | Links |
|---|---|
| Repository | https://gitlab.com/microservice-dungeon/services/trading-service |
| Registry | https://gitlab.com/microservice-dungeon/services/trading-service/container_registry |
| Latest Image | registry.gitlab.com/microservice-dungeon/services/trading-service:latest |
| Changelog | https://gitlab.com/microservice-dungeon/services/trading-service/-/blob/main/CHANGELOG.md |
| AsyncAPI | https://docs.microservice-dungeon.de/docs/reference/trading-service/asyncapi/ |
| Architecture Summary | https://gitlab.com/microservice-dungeon/services/trading-service/-/blob/main/docs/explanations/architecture-summary.md |
| Implementation Details | https://gitlab.com/microservice-dungeon/services/trading-service/-/blob/main/docs/explanations/implementation-details.md |
Development
- Clone the Repo
- (Required if you do not run within IntelliJ or other Java IDEs) - Install Java 21 JDK and set JAVA_HOME to the corresponding path
- Build Project
./mvnw clean compile
Running Tests
This Service uses Maven Surefire and Maven Failsafe to run Tests.
Running Unit Tests:
Either run config UnitTests or
./mvnw test
Running Integration Tests (Requires a valid Docker environment that is accessible to the current shell context)
Either run config IntegrationTests or
./mvnw integration-test
Running all tests (Requires a valid Docker environment that is accessible to the current shell context):
Either run config AllTests or
./mvnw verify
Running with other services
Use the local dev env as described in its readme.
- Start everything except the Trading service itself (you still need the outbox).
- Start the service, either by using the IntelliJ run configuration
run application (local-dev)or using maven (you need the dev-profile to connect to the local dev environment):./mvnw spring-boot:run -Dspring-boot.run.profiles=dev
Quirks
- Testcontainers requires a lower API version than the current minimum requested by Docker 29. (Spring boot dependencies have a workaround, but this could break in the future - see #48104)
CI/CD Pipeline
The pipeline runs on all pushes to main and open merge requests:
- Unit Tests - Runs unit tests, by calling
mvn test - Semantic Release - Automatically determines version bumps and generates changelogs based on commit messages
- Containerize - Builds and pushes Docker images to the GitLab registry
Versioning & Releases
Versions follow semantic versioning (Major.Minor.Patch). The pipeline analyzes commit messages since
the last release to determine the version bump. Only the highest-priority change triggers a bump
(e.g., 10 fixes + 2 features = 1 minor version bump).
Commit message keywords:
| Keyword(s) | Increments |
|---|---|
breaking, major, BREAKING CHANGE |
Major |
feat, minor |
Minor |
fix, patch |
Patch |
perf, refactor |
No bump configured (used for release notes grouping) |
| Others | Hidden in changelog / no bump configured |
Important: Releases only happen on main. Merge request pipelines run in dry-run mode to
preview the next version.
Docker Images
Images are tagged differently based on context:
- Releases:
<version>andlatest - Main branch changes:
<commit-sha> - Merge requests:
SNAPSHOT-<commit-sha>
Gitlab Dependency Proxy
The pipeline uses GitLab’s Dependency Proxy to cache docker images and prevent pull rate limits from docker hub.
The base image eclipse-temurin:21 requires authentication, which is handled in the dependency proxy settings
of the organization. We have a docker hub account registered under th-koeln@innovation-hub.de / thkarchilab.
You can use the credentials with the variables $CI_DEPENDENCY_PROXY_USER and $CI_DEPENDENCY_PROXY_PASSWORD.
Metrics implemented
Below you can find the metrics as they show up in Prometheus (_ instead of .)
| Metric Name | Description |
|---|---|
| service_execution_time | Execution time of application use cases (timer, percentile histograms). Tagged with usecase name. |
| listener_execution_time | Execution time of Kafka listeners. Tagged with listener name. |
| events_published_to_dlt | Number of events published to the dead letter topics. Tagged by topic name (system, intents). Tagged by topic name (system, intents) and Exception type. |
| robots_bought | Total number of robots purchased across all games. |
| upgrades_bought | Total number of upgrade levels purchased (tagged by upgradeType) across all games. |
| encountered_duplicates | Total number of duplicate sequence numbers encountered across all games. |