Skip to content

bitxon/java-microservices

Repository files navigation

Java Microservices

Description

This project is a comparison of Java frameworks. All applications implement the same functionality and expose the same REST api

Quick start

  1. Build
    • ./gradlew clean build
  2. Spin Up Postgres & Wiremock:
    • docker-compose up -d
  3. Start one of the Apps:
    • ./run-dropwizard.sh
    • ./run-spring.sh
    • ./run-micronaut.sh
    • ./run-quarkus.sh
  4. Run Gatling:
    • ./gradlew :loadtest:gatlingRun --simulation gatling.simulation.AppSimulation
Check wiremock performance
  1. Spin Up Wiremock:
    • docker-compose up -d wiremock
  2. Run Gatling:
    • ./gradlew :loadtest:gatlingRun --simulation gatling.simulation.WiremockSimulation

Rest API

GET /accounts - Get all accounts

Request Body:

N/A

Response Body:

[
   {
      "id": 1,
      "email": "john@mail.com",
      "firstName": "John",
      "lastName": "Doe",
      "dateOfBirth": "2000-03-17",
      "currency": "USD",
      "moneyAmount": 78
   }
]
GET /accounts/{id} - Get account by ID

Request Body:

N/A

Response Body:

{
   "id": 1,
   "email": "john@mail.com",
   "firstName": "John",
   "lastName": "Doe",
   "dateOfBirth": "2000-03-17",
   "currency": "USD",
   "moneyAmount": 78
}
POST /accounts - Create new account

Request Body:

{
   "email": "john@mail.com",
   "firstName": "John",
   "lastName": "Doe",
   "dateOfBirth": "2000-03-17",
   "currency": "USD",
   "moneyAmount": 78
}

Response Body:

{
   "id": 1,
   "email": "john@mail.com",
   "firstName": "John",
   "lastName": "Doe",
   "dateOfBirth": "2000-03-17",
   "currency": "USD",
   "moneyAmount": 78
}
POST /accounts/transfer - Transfer money from one account to another

Request Header: (is being used to fail operation and check that transaction works)

Dirty-Trick-Header: FAIL_TRANSFER

Request Body:

{
   "senderId": 1,
   "recipientId": 2,
   "moneyAmount": 100
}

Response Body:

N/A

Diagram:

    sequenceDiagram
        actor User as User
        participant App as Application
        participant DB as Database
        participant Api as Bank Api

        User ->> App: POST /transfer
        activate App
        App ->> DB: Find accounts
        deactivate App
        activate DB
        DB -->> App: Accounts
        deactivate DB
        activate App
        App ->> Api: GET /exchange
        deactivate App
        activate Api
        Api -->> App: Exchange rate
        deactivate Api
        activate App
        App ->> App: Update balance of accounts
        App ->> DB: Save accounts
        deactivate App
        activate DB
        DB -->> App: Done
        deactivate DB
        activate App
        App -->> User: Done
        deactivate App
Loading