Bulk Recall Processing

This workflow processes a batch of affected vehicles concurrently using a Map state with a maximum concurrency of 3. For each vehicle, owner notification and parts ordering are run simultaneously in a Parallel state before scheduling the inspection appointment.
{
  "Comment": "Bulk recall processing: iterates over a batch of affected vehicles concurrently (Map, MaxConcurrency 3). For each vehicle, owner notification and parts ordering run simultaneously (Parallel) before the inspection is scheduled.",
  "StartAt": "ProcessAffectedVehicleBatch",
  "States": {
    "ProcessAffectedVehicleBatch": {
      "Type": "Map",
      "Comment": "Process each affected vehicle in the batch concurrently, up to 3 at a time.",
      "ItemsPath": "$.vehicles",
      "MaxConcurrency": 3,
      "ItemProcessor": {
        "ProcessorConfig": {
          "Mode": "INLINE"
        },
        "StartAt": "ValidateVehicleRecord",
        "States": {
          "ValidateVehicleRecord": {
            "Type": "Task",
            "Resource": "arn:aws:states:::lambda:invoke",
            "Parameters": {
              "FunctionName": "${ValidateRecallFunctionArn}",
              "Payload.$": "$"
            },
            "ResultPath": "$.validation",
            "Retry": [
              {
                "ErrorEquals": [
                  "Lambda.ServiceException",
                  "Lambda.AWSLambdaException",
                  "Lambda.SdkClientException"
                ],
                "IntervalSeconds": 2,
                "MaxAttempts": 2,
                "BackoffRate": 2
              }
            ],
            "Catch": [
              {
                "ErrorEquals": [
                  "States.ALL"
                ],
                "ResultPath": "$.error",
                "Next": "ItemValidationError"
              }
            ],
            "Next": "IsVehicleRecordValid"
          },
          "IsVehicleRecordValid": {
            "Type": "Choice",
            "Choices": [
              {
                "Variable": "$.validation.Payload.isValid",
                "BooleanEquals": true,
                "Next": "NotifyAndOrderParts"
              }
            ],
            "Default": "SkipInvalidRecord"
          },
          "SkipInvalidRecord": {
            "Type": "Succeed"
          },
          "ItemValidationError": {
            "Type": "Fail",
            "Error": "ValidationError",
            "Cause": "Recall validation lambda failed unexpectedly"
          },
          "NotifyAndOrderParts": {
            "Type": "Parallel",
            "Comment": "Notify vehicle owner and order replacement parts simultaneously.",
            "Branches": [
              {
                "StartAt": "NotifyVehicleOwner",
                "States": {
                  "NotifyVehicleOwner": {
                    "Type": "Task",
                    "Resource": "arn:aws:states:::lambda:invoke",
                    "Parameters": {
                      "FunctionName": "${NotifyOwnerFunctionArn}",
                      "Payload.$": "$.validation.Payload"
                    },
                    "End": true
                  }
                }
              },
              {
                "StartAt": "OrderPartsForVehicle",
                "States": {
                  "OrderPartsForVehicle": {
                    "Type": "Task",
                    "Resource": "arn:aws:states:::lambda:invoke",
                    "Parameters": {
                      "FunctionName": "${OrderReplacementPartsFunctionArn}",
                      "Payload.$": "$.validation.Payload"
                    },
                    "End": true
                  }
                }
              }
            ],
            "ResultPath": "$.parallel",
            "Next": "ScheduleVehicleInspection"
          },
          "ScheduleVehicleInspection": {
            "Type": "Task",
            "Resource": "arn:aws:states:::lambda:invoke",
            "Parameters": {
              "FunctionName": "${ScheduleInspectionFunctionArn}",
              "Payload.$": "$.validation.Payload"
            },
            "ResultPath": "$.inspection",
            "End": true
          }
        }
      },
      "ResultPath": "$.processedVehicles",
      "End": true
    }
  }
}
JSON
Expand
100%

Automotive teams can use patterns like this to build reliable, compliant, and scalable automation for payment systems and can test and refine these flows locally with Thrubit to reduce cloud cost and speed up iteration.

Free Trial