This project contains three microservices to facilitate the creation of PoCs for API gateway technologies and frameworks. To support simulation of real world service behaviour, these services allow annotation-based simulation of service latencies as well as service failures.
These services have originally been devised during a master thesis on GraphQL.
Services are based on the following Stack:
-
Java 21 as latest LTS Version
-
Spring Boot 3.2.2
-
Maven
-
Postgres
-
Docker via JIB
👉
|
Why are these services no Spring Data REST Projects? Most of the services are not more than exposing REST APIs for CRUD operations on specific entities and would hence be ideal candidates for Spring Data REST. However, since being able to modify specific API and service behaviours on the fly is key for using these services in PoCs, a manual approach to service creation was applied. |
Service | Domain Objects | Authentication | Request ID for Logging |
---|---|---|---|
Customer Service |
Customer Information, Customer Networks |
API Key |
Request Epoch as Request ID |
Product Service |
Product Information, Product Reviews |
Basic Auth |
UUID |
ECommerce Service |
Purchases, Price Information |
Basic Auth |
UID |
Provides two distinct services:
-
Customer Information: Allowing CRUD operations focussed on personal data of customers
-
Customer Network: Storing and querying of relationships between customers
Product Service also provides services on two distinct domains:
-
Product Information: Provides REST APIs for retrieval, editing and creation of product information.
-
Product Reviews: Exposes endpoints for basic functionality to review products.
In order to support simulation of specific integration challenges such as unstable services or services with high latencies, two additional functionalities are provided:
Services can be configured in the respective application properties to incorporate "lag" based on three distinct approaches:
These lag simulations can be activated by adding @EnableDelaySimulation
on a class in the spring context.
-
Fixed Delay: Calls to all endpoints exposed by this service exhibit a fixed delay.
-
Normally Distributed Random Delay: Calls to all endpoints exposed by this service exhibit a random delay following a gaussian distribution with configurable mean and standard deviation.
-
Probabilistic Delay: Calls to all endpoints to this service either exhibit no or a fixed amount of delay, based on a probability that can be set. This is intended to simulate wake up behavior or less reliable downstream services.
Similar to the overall delay approaches, all endpoints can be used to simulate similar delays by adding annotation to the respective controller functions:
-
Fixed Delay:
@FixedDelaySimulation
, providingdelayInMs
-
Normally Distributed Random Delay:
@NormallyDistributedDelaySimulation
, providingmean
andstandardDeviation
-
Probabilistic Delay:
@ProbabilisticDelaySimulation
, providingprobability`and `delayInMs
These endpoint-specific delays can be used to simulate different service response times with respect to server loads and average query response times.
Based on controller or rest endpoint level, probabilities for failures (as represented by 4 and 5 status code responses) can be set.
This simulated error behaviour can be enabled by adding @EnableFailureSimulation
on a class in the spring context.
Adding the @ProbabilisticFailureSimulation
(providing both probability
and errorCode
) on class or method level enables failure simulation.
All services can be run using the local
profile without any additional required setup.
This will use a H2 in memory database as persistence layer for each simulated service.
If run in local
profile, some test data and default users are set up for the respective service during start up. For services with basic auth, user credentials for these users follow the same pattern for all services:
-
User name:
$service_$role
(e.g.productservice_user
) -
Password:
$service_$role_password
(e.g.productservice_user_password
)
When using the local
profile services will expose their APIs as follows:
Service | URI | Port | Username | Password | API Key |
---|---|---|---|---|---|
Customer Service |
8082 |
- |
- |
|
|
eCommerce Service |
8083 |
|
|
- |
|
Product Service |
8081 |
|
|
- |
Additionally, the JIB Maven plugin has been preconfigured to allow easy dockerization of the services.
Images can be created by running mvn clean package jib:dockerBuild
for a local Docker Daemon. To push to a remote docker registry, a <to>
tag must be added to the configuration as described here.
Dockerized services will be using the docker
profile by default. This profile causes the same application behavior as the local
profile described above.
A complete postman collection as well as a postman environment for the local setup is available as part of this repository.