simple_statelang_with_compensation.json 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. {
  2. "Name": "simpleCompensationStateMachine",
  3. "Comment": "带补偿定义的测试状态机定义",
  4. "StartState": "FirstState",
  5. "Version": "0.0.1",
  6. "States": {
  7. "FirstState": {
  8. "Type": "ServiceTask",
  9. "ServiceName": "demoService",
  10. "ServiceMethod": "foo",
  11. "CompensateState": "CompensateFirstState",
  12. "Next": "ChoiceState",
  13. "Input": [
  14. {
  15. "fooInput": "$.[a]",
  16. "throwException": "$.[fooThrowException]",
  17. "sleepTime": "$.[fooSleepTime]"
  18. }
  19. ],
  20. "Output": {
  21. "fooResult": "$.#root"
  22. },
  23. "Status": {
  24. "$Exception{io.seata.saga.engine.mock.DemoException}": "UN",
  25. "#root != null": "SU",
  26. "#root == null": "FA"
  27. },
  28. "Catch": [
  29. {
  30. "Exceptions": [
  31. "io.seata.saga.engine.mock.DemoException"
  32. ],
  33. "Next": "CompensationTrigger"
  34. }
  35. ]
  36. },
  37. "ChoiceState":{
  38. "Type": "Choice",
  39. "Choices":[
  40. {
  41. "Expression":"[a] == 1",
  42. "Next":"SecondState"
  43. },
  44. {
  45. "Expression":"[a] == 2",
  46. "Next":"ThirdState"
  47. }
  48. ],
  49. "Default":"Fail"
  50. },
  51. "SecondState": {
  52. "Type": "ServiceTask",
  53. "ServiceName": "demoService",
  54. "ServiceMethod": "bar",
  55. "CompensateState": "CompensateSecondState",
  56. "Input": [
  57. {
  58. "barInput": "$.[fooResult]",
  59. "throwException": "$.[barThrowException]",
  60. "sleepTime": "$.[barSleepTime]"
  61. }
  62. ],
  63. "Output": {
  64. "barResult": "$.#root"
  65. },
  66. "Status": {
  67. "$Exception{io.seata.saga.engine.mock.DemoException}": "UN",
  68. "#root != null": "SU",
  69. "#root == null": "FA"
  70. },
  71. "Catch": [
  72. {
  73. "Exceptions": [
  74. "io.seata.saga.engine.mock.DemoException"
  75. ],
  76. "Next": "CompensationTrigger"
  77. }
  78. ],
  79. "Next": "Succeed"
  80. },
  81. "ThirdState": {
  82. "Type": "ServiceTask",
  83. "ServiceName": "demoService",
  84. "ServiceMethod": "foo",
  85. "Input": [
  86. {
  87. "fooInput": "$.[fooResult]"
  88. }
  89. ],
  90. "Output": {
  91. "fooResult": "$.#root"
  92. },
  93. "Next": "Succeed"
  94. },
  95. "CompensateFirstState": {
  96. "Type": "ServiceTask",
  97. "ServiceName": "demoService",
  98. "ServiceMethod": "compensateFoo",
  99. "Input": [
  100. {
  101. "compensateFooInput": "$.[fooResult]",
  102. "throwException": "$.[compensateFooThrowException]"
  103. }
  104. ]
  105. },
  106. "CompensateSecondState": {
  107. "Type": "ServiceTask",
  108. "ServiceName": "demoService",
  109. "ServiceMethod": "compensateBar",
  110. "Input": [
  111. {
  112. "compensateBarInput": "$.[barResult]",
  113. "throwException": "$.[compensateBarThrowException]"
  114. }
  115. ]
  116. },
  117. "CompensationTrigger": {
  118. "Type": "CompensationTrigger",
  119. "Next": "Fail"
  120. },
  121. "Succeed": {
  122. "Type":"Succeed"
  123. },
  124. "Fail": {
  125. "Type":"Fail",
  126. "ErrorCode": "NOT_FOUND",
  127. "Message": "not found"
  128. }
  129. }
  130. }