| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- {
- "Name": "simpleLoopTestStateMachine",
- "Comment": "带循环参数的测试状态机定义",
- "StartState": "FirstState",
- "Version": "0.0.1",
- "States": {
- "FirstState": {
- "Type": "ServiceTask",
- "ServiceName": "demoService",
- "ServiceMethod": "foo",
- "CompensateState": "CompensateFirstState",
- "Loop": {
- "Parallel": 3,
- "Collection": "$.[collection]",
- "ElementVariableName": "element",
- "ElementIndexName": "loopCounter",
- "CompletionCondition": "[nrOfCompletedInstances] == ([collection].size()-4)"
- },
- "Input": [
- {
- "loopCounter": "$.[loopCounter]",
- "element": "$.[element]",
- "throwException": "$.[fooThrowException]"
- }
- ],
- "Output": {
- "fooResult": "$.#root"
- },
- "Next": "ChoiceState"
- },
- "ChoiceState":{
- "Type": "Choice",
- "Choices":[
- {
- "Expression": "[loopResult].?[#this[fooResult] == null].size() == 0 && [a] == 1",
- "Next":"SecondState"
- },
- {
- "Expression": "[loopResult].?[#this[fooResult] == null].size() == 0 && [a] == 2",
- "Next":"CallSubStateMachine"
- }
- ],
- "Default":"Fail"
- },
- "SecondState": {
- "Type": "ServiceTask",
- "ServiceName": "demoService",
- "ServiceMethod": "bar",
- "CompensateState": "CompensateSecondState",
- "Loop": {
- "Parallel": 3,
- "Collection": "$.[collection]",
- "ElementVariableName": "element",
- "CompletionCondition": "[nrOfCompletedInstances] / [nrOfInstances] >= 0.4",
- "ElementIndexName": "loopCounter"
- },
- "Input": [
- {
- "loopCounter": "$.[loopCounter]",
- "loopElement": "$.[element]",
- "throwException": "$.[barThrowException]"
- }
- ],
- "Catch": [
- {
- "Exceptions": [
- "io.seata.saga.engine.mock.DemoException"
- ],
- "Next": "CompensationTriggerTest"
- }
- ]
- },
- "CallSubStateMachine": {
- "Type": "SubStateMachine",
- "StateMachineName": "simpleCompensationStateMachine",
- "Loop": {
- "Parallel": 3,
- "Collection": "$.[collection]",
- "ElementVariableName": "element",
- "CompletionCondition": "[nrOfCompletedInstances] / [nrOfInstances] >= 0.4",
- "ElementIndexName": "loopCounter"
- },
- "Input": [
- {
- "a": 1,
- "collection": "$.[collection]",
- "loopCounter": "$.[loopCounter]",
- "element": "$.[element]",
- "barThrowException": "$.[barThrowException]",
- "fooThrowException": "$.[fooThrowException]",
- "compensateFooThrowException": "$.[compensateFooThrowException]"
- }
- ],
- "Output": {
- "fooResult": "$.#root"
- },
- "Next": "Succeed"
- },
- "CompensateFirstState": {
- "Type": "ServiceTask",
- "ServiceName": "demoService",
- "ServiceMethod": "compensateFoo",
- "Input": [
- {
- "compensateFooInput": "$.[fooResult]",
- "throwException": "$.[compensateFooThrowException]",
- "loopCounter": "$.[loopCounter]",
- "element": "$.[element]"
- }
- ]
- },
- "CompensateSecondState": {
- "Type": "ServiceTask",
- "ServiceName": "demoService",
- "ServiceMethod": "compensateBar",
- "Input": [
- {
- "compensateBarInput": "$.[barResult]",
- "loopCounter": "$.[loopCounter]",
- "loopElement": "$.[element]"
- }
- ]
- },
- "CompensationTriggerTest": {
- "Type": "CompensationTrigger",
- "Next": "Fail"
- },
- "Succeed": {
- "Type":"Succeed"
- },
- "Fail": {
- "Type":"Fail",
- "ErrorCode": "NOT_FOUND",
- "Message": "not found"
- }
- }
- }
|