Showing posts with label Microservice. Show all posts
Showing posts with label Microservice. Show all posts
Thursday, May 24, 2018
Multiple phases commit
psedocode
client invokes System A
System A performs process
if success
System A commits
System A invokes System B
System B performs process
if success
System B commits
System B invokes System N..
System N.. performs process
if success
System N.. commits
else
System N.. rollback
System N.. return false
else
System B rollback
System B return false
else
System A rollback
System A returns fail
to simplified the above logic,
1. process and commit own transaction.
2. invoke external system/process
3.1 if success, return true
3.2 if failed, return false, manual rollback the transaction.
Done!!
Wednesday, May 16, 2018
Manual rollback with MongoDB
When there is a need to save different documents at the same time in microservices, or more specifically NoSql.
It is not an easy job, because NoSql does not support transaction like RDBMS.
The multiple phases commit in the previous post able to achieve the transaction-like behavior with MongoDB.
The code snippet below will be demonstrated by Play2.x, MongoDB, Morphia.
Done!!
It is not an easy job, because NoSql does not support transaction like RDBMS.
The multiple phases commit in the previous post able to achieve the transaction-like behavior with MongoDB.
The code snippet below will be demonstrated by Play2.x, MongoDB, Morphia.
JsonNode json = request().body().asJson();
MyDocument md = Json.fromJson(json, MyDocument.class);
MyDocument mdCurrent = MyDocumentRepo.findMyDocumentById( md.getId() );
MyDocumentRepo.save( md );
boolean status = callNextService();
if(status == true) {
// not doing anything
} else {
// manually rollback the previous md
MyDocumentRepo.save( mdCurrent );
}
Done!!
Wednesday, October 25, 2017
How to create new Play Java project
1. make sure sbt is installed in your OS
2. create a new folder, eg. "my-play-project"
3. open command prompt, and navigate to the newly create folder
4. in the command prompt, type "sbt new playframework/play-java-seed.g8"
a) enter project name
b) enter organization
c) enter scala version
d) enter play version
e) enter sbt version
2. create a new folder, eg. "my-play-project"
3. open command prompt, and navigate to the newly create folder
4. in the command prompt, type "sbt new playframework/play-java-seed.g8"
a) enter project name
b) enter organization
c) enter scala version
d) enter play version
e) enter sbt version
Subscribe to:
Posts (Atom)
Popular Posts
- How to create database view with Oracle SQL Developer Data Modeler
- Primefaces fileDownload in Liferay
- How to enable CKEditor in PrimeFaces Extension
- How to backup Oracle SQL Developer Data Modeler project
- Eclipselink Cache Coordination with JBoss and JMS
- How to handle multilingual error messages for jQuery validation plugins
- Import/Export MySQL database with SQLyog
- Handling Many-to-Many relationship in relational model
- How to edit Liferay email notification templates
- How to easily embed a Google Map in your website