simple_statelang_with_script.json 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. {
  2. "Name": "simpleScriptTaskStateMachine",
  3. "Comment": "带ScriptTask的测试状态机定义",
  4. "StartState": "FirstState",
  5. "Version": "0.0.1",
  6. "States": {
  7. "FirstState": {
  8. "Type": "ServiceTask",
  9. "ServiceName": "demoService",
  10. "ServiceMethod": "foo",
  11. "Next": "ScriptState",
  12. "Input": [
  13. {
  14. "fooInput": "$.[a]"
  15. }
  16. ],
  17. "Output": {
  18. "fooResult": "$.#root"
  19. }
  20. },
  21. "ScriptState": {
  22. "Type": "ScriptTask",
  23. "ScriptType": "groovy",
  24. "ScriptContent": "if(throwException){ throw new RuntimeException(\"test\") } else { 'hello ' + inputA }",
  25. "Input": [
  26. {
  27. "inputA": "$.[a]",
  28. "throwException": "$.[scriptThrowException]"
  29. }
  30. ],
  31. "Output": {
  32. "scriptStateResult": "$.#root"
  33. },
  34. "Catch": [
  35. {
  36. "Exceptions": [
  37. "java.lang.Throwable"
  38. ],
  39. "Next": "Fail"
  40. }
  41. ],
  42. "Next": "ChoiceState"
  43. },
  44. "ChoiceState":{
  45. "Type": "Choice",
  46. "Choices":[
  47. {
  48. "Expression":"[a] == 1",
  49. "Next":"SecondState"
  50. },
  51. {
  52. "Expression":"[a] == 2",
  53. "Next":"ThirdState"
  54. }
  55. ],
  56. "Default":"Fail"
  57. },
  58. "SecondState": {
  59. "Type": "ServiceTask",
  60. "ServiceName": "demoService",
  61. "ServiceMethod": "bar",
  62. "Input": [
  63. {
  64. "barInput": "$.[fooResult]",
  65. "throwException": "$.[barThrowException]"
  66. }
  67. ],
  68. "Output": {
  69. "barResult": "$.#root"
  70. },
  71. "Catch": [
  72. {
  73. "Exceptions": [
  74. "io.seata.saga.engine.mock.DemoException"
  75. ],
  76. "Next": "Fail"
  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. "Succeed": {
  96. "Type":"Succeed"
  97. },
  98. "Fail": {
  99. "Type":"Fail",
  100. "ErrorCode": "NOT_FOUND",
  101. "Message": "not found"
  102. }
  103. }
  104. }