Skip to content

Latest commit

 

History

History

201801-transactions-microservices

Transactions for Microservices?

Overview

This presentation illustrates the use of compensating transactions. The material outlines the problems associated with the use of full-ACID and identifies how a technique known as Long Running Actions can be a better fit.

Usage 1: Local

The demonstator is fully automated via the run.sh script. Different versions of Narayana can be configured with the appropriate environment variable:

<NARAYANA_VERSION=...> ./run.sh

The final output that is expected is:

Running close case
{
  "id": "http://localhost:8080/lra-coordinator/0_ffffc0a86301_-20bd81f2_5a65ddb3_13",
  "name": "Aggregate Booking",
  "status": "CONFIRMED",
  "details": [
    {
      "id": "http://localhost:8080/lra-coordinator/0_ffffc0a86301_-20bd81f2_5a65ddb3_13",
      "name": "TheGrand",
      "status": "CONFIRMED",
      "details": []
    },
    {
      "id": "http://localhost:8081/lra-coordinator/0_ffffc0a86301_-5ad63e44_5a65ddb3_16",
      "name": "firstClass",
      "status": "CANCELLED",
      "details": []
    },
    {
      "id": "http://localhost:8081/lra-coordinator/0_ffffc0a86301_-5ad63e44_5a65ddb3_1b",
      "name": "economy",
      "status": "CONFIRMED",
      "details": []
    }
  ]
}
Running cancel case
{
  "id": "http://localhost:8080/lra-coordinator/0_ffffc0a86301_-20bd81f2_5a65ddb3_1c",
  "name": "Aggregate Booking",
  "status": "CANCELLED",
  "details": [
    {
      "id": "http://localhost:8080/lra-coordinator/0_ffffc0a86301_-20bd81f2_5a65ddb3_1c",
      "name": "TheGrand",
      "status": "CANCELLED",
      "details": []
    },
    {
      "id": "http://localhost:8081/lra-coordinator/0_ffffc0a86301_-5ad63e44_5a65ddb3_20",
      "name": "firstClass",
      "status": "CANCELLED",
      "details": []
    },
    {
      "id": "http://localhost:8081/lra-coordinator/0_ffffc0a86301_-5ad63e44_5a65ddb3_24",
      "name": "economy",
      "status": "CANCELLED",
      "details": []
    }
  ]
}

Usage 2: OpenShift

Assuming you have Minishift installed (https://docs.openshift.org/latest/minishift/getting-started/installing.html) you should be able to run using:

./minishift.sh

The final output that is expected is:

Running example with crash
The booking ID for http://trip-transactionsmicroservices.192.168.99.100.nip.io/?hotelName=TheGrand&flightNumber1=BA123&flightNumber2=RH456 was: http://lra-coordinator:8080/lra-coordinator/0_ffffac110003_20bf54d3_5a65f0ba_28
Uploading directory "." as binary input for the build ...
build "lra-coordinator-2" started
Receiving source from STDIN as archive ...
Step 1 : FROM fabric8/java-jboss-openjdk8-jdk:1.2.3
 ---> 7a2a8001c977
Step 2 : ENV JAVA_APP_JAR lra-coordinator-swarm.jar
 ---> Using cache
 ---> 4e05b6cef359
Step 3 : ENV AB_ENABLED off
 ---> Using cache
 ---> d5d703242057
Step 4 : ENV JAVA_OPTIONS -Xmx512m -Dswarm.transactions.object-store-path=../../data
 ---> Using cache
 ---> 6bae697d3c8d
Step 5 : EXPOSE 8080
 ---> Using cache
 ---> cf90d3e7ff32
Step 6 : ADD target/lra-coordinator-swarm.jar /deployments/
 ---> Using cache
 ---> 6ea21f8fad9e
Step 7 : ENV "OPENSHIFT_BUILD_NAME" "lra-coordinator-2" "OPENSHIFT_BUILD_NAMESPACE" "transactionsmicroservices"
 ---> Running in 8edd74dee11d
 ---> 3c26ad25a5da
Removing intermediate container 8edd74dee11d
Step 8 : LABEL "io.openshift.build.namespace" "transactionsmicroservices" "io.openshift.build.name" "lra-coordinator-2"
 ---> Running in c47bb78fb930
 ---> 10bacdc51a92
Removing intermediate container c47bb78fb930
Successfully built 10bacdc51a92

Pushing image 172.30.1.1:5000/transactionsmicroservices/lra-coordinator:latest ...
Pushed 3/12 layers, 25% complete
Pushed 4/12 layers, 33% complete
Pushed 5/12 layers, 42% complete
Pushed 6/12 layers, 50% complete
Pushed 7/12 layers, 58% complete
Pushed 8/12 layers, 67% complete
Pushed 9/12 layers, 75% complete
Pushed 10/12 layers, 83% complete
Pushed 11/12 layers, 92% complete
Pushed 12/12 layers, 100% complete
Push successful
/cygdrive/c/Users/still/Documents/jbosstm/conferences/201801-transactions-microservices
Waiting for the coordinator to recover
W0122 14:29:21.842239    4916 cmd.go:373] log is DEPRECATED and will be removed in a future version. Use logs instead.
2018-01-22 14:13:16,737 INFO  [org.wildfly.swarm] (main) WFSWARM99999: WildFly Swarm is Ready




Confirming with curl -X PUT http://trip-transactionsmicroservices.192.168.99.100.nip.io/http%3A%2F%2Flra-coordinator%3A8080%2Flra-coordinator%2F0_ffffac110003_20bf54d3_5a65f0ba_28
{
  "id": "http://lra-coordinator:8080/lra-coordinator/0_ffffac110003_20bf54d3_5a65f0ba_28",
  "name": "Aggregate Booking",
  "status": "CONFIRMED",
  "details": [
    {
      "id": "http://lra-coordinator:8080/lra-coordinator/0_ffffac110003_20bf54d3_5a65f0ba_28",
      "name": "TheGrand",
      "status": "CONFIRMED",
      "details": []
    },
    {
      "id": "http://flight-lra-coordinator:8080/lra-coordinator/0_ffffac110006_10b96d55_5a65f0dd_24",
      "name": "firstClass",
      "status": "CANCELLED",
      "details": []
    },
    {
      "id": "http://flight-lra-coordinator:8080/lra-coordinator/0_ffffac110006_10b96d55_5a65f0dd_28",
      "name": "economy",
      "status": "CONFIRMED",
      "details": []
    }
  ]
}
Ran fine