simple_statemachine.json 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. {
  2. "Name": "simpleTestStateMachine",
  3. "Comment": "测试状态机定义",
  4. "StartState": "FirstState",
  5. "Version": "0.0.1",
  6. "States": {
  7. "FirstState": {
  8. "Type": "ServiceTask",
  9. "ServiceName": "is.seata.saga.DemoService",
  10. "ServiceMethod": "foo",
  11. "IsPersist": false,
  12. "Next": "ScriptState"
  13. },
  14. "ScriptState": {
  15. "Type": "ScriptTask",
  16. "ScriptType": "groovy",
  17. "ScriptContent": "return 'hello ' + inputA",
  18. "Input": [
  19. {
  20. "inputA": "$.data1"
  21. }
  22. ],
  23. "Output": {
  24. "scriptStateResult": "$.#root"
  25. },
  26. "Next": "ChoiceState"
  27. },
  28. "ChoiceState": {
  29. "Type": "Choice",
  30. "Choices": [
  31. {
  32. "Expression": "foo == 1",
  33. "Next": "FirstMatchState"
  34. },
  35. {
  36. "Expression": "foo == 2",
  37. "Next": "SecondMatchState"
  38. }
  39. ],
  40. "Default": "FailState"
  41. },
  42. "FirstMatchState": {
  43. "Type": "ServiceTask",
  44. "ServiceName": "is.seata.saga.DemoService",
  45. "ServiceMethod": "bar",
  46. "CompensateState": "CompensateFirst",
  47. "Status": {
  48. "return.code == 'S'": "SU",
  49. "return.code == 'F'": "FA",
  50. "$exception{java.lang.Throwable}": "UN"
  51. },
  52. "Input": [
  53. {
  54. "inputA1": "$.data1",
  55. "inputA2": {
  56. "a": "$.data2.a"
  57. }
  58. },
  59. {
  60. "inputB": "$.header"
  61. }
  62. ],
  63. "Output": {
  64. "firstMatchStateResult": "$.#root"
  65. },
  66. "Retry": [
  67. {
  68. "Exceptions": ["java.lang.Exception"],
  69. "IntervalSeconds": 2,
  70. "MaxAttempts": 3,
  71. "BackoffRate": 1.5
  72. }
  73. ],
  74. "Catch": [
  75. {
  76. "Exceptions": [
  77. "java.lang.Exception"
  78. ],
  79. "Next": "CompensationTrigger"
  80. }
  81. ],
  82. "Next": "SuccessState"
  83. },
  84. "CompensateFirst": {
  85. "Type": "ServiceTask",
  86. "ServiceName": "is.seata.saga.DemoService",
  87. "ServiceMethod": "compensateBar",
  88. "IsForCompensation": true,
  89. "IsForUpdate": true,
  90. "Input": [
  91. {
  92. "input": "$.data"
  93. }
  94. ],
  95. "Output": {
  96. "firstMatchStateResult": "$.#root"
  97. },
  98. "Status": {
  99. "return.code == 'S'": "SU",
  100. "return.code == 'F'": "FA",
  101. "$exception{java.lang.Throwable}": "UN"
  102. }
  103. },
  104. "CompensationTrigger": {
  105. "Type": "CompensationTrigger",
  106. "Next": "CompensateEndState"
  107. },
  108. "CompensateEndState": {
  109. "Type": "Fail",
  110. "ErrorCode": "StateCompensated",
  111. "Message": "State Compensated!"
  112. },
  113. "SecondMatchState": {
  114. "Type": "SubStateMachine",
  115. "StateMachineName": "simpleTestStateMachine",
  116. "Input": [
  117. {
  118. "input": "$.data"
  119. },
  120. {
  121. "header": "$.header"
  122. }
  123. ],
  124. "Output": {
  125. "firstMatchStateResult": "$.#root"
  126. },
  127. "Next": "SuccessState"
  128. },
  129. "FailState": {
  130. "Type": "Fail",
  131. "ErrorCode": "DefaultStateError",
  132. "Message": "No Matches!"
  133. },
  134. "SuccessState": {
  135. "Type": "Succeed"
  136. }
  137. }
  138. }