複数の処理でエラーがあっても、他の処理は進行を続ける方法
2つの処理の流れがある、次のフローについてです。
設計のプレビュー(両方がエラーの例)
ポイント紹介
IsErrorをセットする PARA_A_SUCCESSからPARA_B_ERRORは、
{
"IsError": "True"
}
のように書くのみです。(ResultPathを使用して・・・といった他のチェックは無し)
これらの載っている BASE_1 パラレルステートで、
チェック入れる:ResultPath を使用して元の入力を出力に追加 - 省略可能
Combine Original input with result
$.BASE_1_Result
この組み合わせをしていくと、うまく保持されます。
BASE_GROUPはパラレル処理結果は配列でfalse trueの組み合わせだったりするので、1つのtrueにする、ようにして、結果を出力しています。
上記のをシーケンシャルに2つ繋げたケース
2つ繋げたケースのソースコード
{
"Comment": "A description of my state machine",
"StartAt": "BASE_1_GROUP",
"States": {
"BASE_1_GROUP": {
"Type": "Parallel",
"Branches": [
{
"StartAt": "BASE_1",
"States": {
"BASE_1": {
"Type": "Parallel",
"Branches": [
{
"StartAt": "BASE_1_PARA_A",
"States": {
"BASE_1_PARA_A": {
"Type": "Parallel",
"Branches": [
{
"StartAt": "BASE_1_PARA_A_JOB_1",
"States": {
"BASE_1_PARA_A_JOB_1": {
"Type": "Wait",
"Seconds": 5,
"Next": "BASE_1_PARA_A_JOB_2"
},
"BASE_1_PARA_A_JOB_2": {
"Type": "Pass",
"End": true
}
}
}
],
"Next": "BASE_1_PARA_A_SUCCESS",
"Catch": [
{
"ErrorEquals": [
"States.ALL"
],
"Next": "BASE_1_PARA_A_ERROR"
}
]
},
"BASE_1_PARA_A_ERROR": {
"Type": "Pass",
"End": true,
"Result": {
"IsError": "True"
}
},
"BASE_1_PARA_A_SUCCESS": {
"Type": "Pass",
"End": true,
"Result": {
"IsError": "False"
}
}
}
},
{
"StartAt": "BASE_1_PARA_B",
"States": {
"BASE_1_PARA_B": {
"Type": "Parallel",
"Branches": [
{
"StartAt": "BASE_1_PARA_B_JOB_1",
"States": {
"BASE_1_PARA_B_JOB_1": {
"Type": "Pass",
"Next": "BASE_1_PARA_B_Fail"
},
"BASE_1_PARA_B_Fail": {
"Type": "Fail"
}
}
}
],
"Catch": [
{
"ErrorEquals": [
"States.ALL"
],
"Next": "BASE_1_PARA_B_ERROR"
}
],
"Next": "BASE_1_PARA_B_SUCCESS"
},
"BASE_1_PARA_B_SUCCESS": {
"Type": "Pass",
"End": true,
"Result": {
"IsError": "False"
}
},
"BASE_1_PARA_B_ERROR": {
"Type": "Pass",
"End": true,
"Result": {
"IsError": "True"
}
}
}
}
],
"Next": "BASE_1_CHECK",
"ResultPath": "$.BASE_1_Result"
},
"BASE_1_CHECK": {
"Type": "Choice",
"Choices": [
{
"Or": [
{
"Variable": "$.BASE_1_Result[0].IsError",
"StringEquals": "True"
},
{
"Variable": "$.BASE_1_Result[1].IsError",
"StringEquals": "True"
}
],
"Next": "BASE_1_FAILED"
}
],
"Default": "BASE_1_SUCCESS"
},
"BASE_1_FAILED": {
"Type": "Pass",
"Result": {
"IsError": "True"
},
"End": true
},
"BASE_1_SUCCESS": {
"Type": "Pass",
"Result": {
"IsError": "False"
},
"End": true
}
}
}
],
"Next": "BASE_2_GROUP",
"ResultPath": "$.BASE_1_Result"
},
"BASE_2_GROUP": {
"Type": "Parallel",
"Branches": [
{
"StartAt": "BASE_2",
"States": {
"BASE_2": {
"Type": "Parallel",
"Branches": [
{
"StartAt": "BASE_2_PARA_A",
"States": {
"BASE_2_PARA_A": {
"Type": "Parallel",
"Branches": [
{
"StartAt": "BASE_2_PARA_A_JOB_1",
"States": {
"BASE_2_PARA_A_JOB_1": {
"Type": "Wait",
"Seconds": 5,
"Next": "BASE_2_PARA_A_JOB_2"
},
"BASE_2_PARA_A_JOB_2": {
"Type": "Pass",
"End": true
}
}
}
],
"Next": "BASE_2_PARA_A_SUCCESS",
"Catch": [
{
"ErrorEquals": [
"States.ALL"
],
"Next": "BASE_2_PARA_A_ERROR"
}
]
},
"BASE_2_PARA_A_ERROR": {
"Type": "Pass",
"End": true,
"Result": {
"IsError": "True"
}
},
"BASE_2_PARA_A_SUCCESS": {
"Type": "Pass",
"End": true,
"Result": {
"IsError": "False"
}
}
}
},
{
"StartAt": "BASE_2_PARA_B",
"States": {
"BASE_2_PARA_B": {
"Type": "Parallel",
"Branches": [
{
"StartAt": "BASE_2_PARA_B_JOB_1",
"States": {
"BASE_2_PARA_B_JOB_1": {
"Type": "Pass",
"End": true
}
}
}
],
"Catch": [
{
"ErrorEquals": [
"States.ALL"
],
"Next": "BASE_2_PARA_B_ERROR"
}
],
"Next": "BASE_2_PARA_B_SUCCESS"
},
"BASE_2_PARA_B_SUCCESS": {
"Type": "Pass",
"End": true,
"Result": {
"IsError": "False"
}
},
"BASE_2_PARA_B_ERROR": {
"Type": "Pass",
"End": true,
"Result": {
"IsError": "True"
}
}
}
}
],
"Next": "BASE_2_CHECK",
"ResultPath": "$.BASE_2_Result"
},
"BASE_2_CHECK": {
"Type": "Choice",
"Choices": [
{
"Or": [
{
"Variable": "$.BASE_2_Result[0].IsError",
"StringEquals": "True"
},
{
"Variable": "$.BASE_2_Result[1].IsError",
"StringEquals": "True"
}
],
"Next": "BASE_2_FAILED"
}
],
"Default": "BASE_2_SUCCESS"
},
"BASE_2_FAILED": {
"Type": "Pass",
"Result": {
"IsError": "True"
},
"End": true
},
"BASE_2_SUCCESS": {
"Type": "Pass",
"Result": {
"IsError": "False"
},
"End": true
}
}
}
],
"Next": "BASE_3",
"ResultPath": "$.BASE_2_Result"
},
"BASE_3": {
"Type": "Pass",
"Result": {
"IsError": "False"
},
"ResultPath": "$.BASE_2_Result",
"End": true
}
}
}