A simple service to demonstrate how to user Java Lock to make safe transfer between accounts with support for multi-threading.
You can create multiple accounts using the same owner name; however, the generated account id is unique
- Java 1.8
- dropwizard
- guice: In this release, dependency injection is used in the test code only
- mvn package
- cd target
- java -jar banking-1.0-SNAPSHOT.jar server /banking-service.yml
####Create Account1:
#####curl -X POST "http://localhost:8080/api/v1/account" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"ownerFirstName\": \"Radwan\", \"ownerLastName\": \"Nizam\", \"balance\": 100}"
' { "id": "1", "ownerFirstName": "Radwan", "ownerLastName": "Nizam", "balance": 100, "creationDate": 1570432944587 } '
####Create Account2:
#####curl -X POST "http://localhost:8080/api/v1/account" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"ownerFirstName\": \"George\", \"ownerLastName\": \"Brown\", \"balance\": 100}"
' { "id": "2", "ownerFirstName": "George", "ownerLastName": "Brown", "balance": 100, "creationDate": 1570432945587 } '
####Transfer Money (success):
curl -X POST "http://localhost:8080/api/v1/account/actions/transfer/invoke" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"source\": \"1\", \"target\": \"2\", \"amount\": 100}"
code 202
####Transfer Money (failed):
curl -X POST "http://localhost:8080/api/v1/account/actions/transfer/invoke" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"source\": \"1\", \"target\": \"2\", \"amount\": 100}"
code 500
{ "code": 5, "message": "insufficient funds" }