Search code examples
amazon-web-servicesamazon-swfaws-php-sdk

AWS Simple Workflow - respondDecisionTaskCompleted Not Working?


I am currently using the PHP SDK for SWF. I successfully pull decision tasks using:

$result = $client->pollForDecisionTask(array(
    "domain" => "test",
    "taskList" => array(
        "name" => "mainTaskList"
    ),
    "identify" => "default",
    "maximumPageSize" => 50,
    "reverseOrder" => true
));

$activity_type_version = "1.0";

$task_token = $result["taskToken"];
$run_id = $result["workflowExecution"]["runId"];
$last_event = $result["events"][0]["eventId"];

if($last_event == "3"){
    $activity_type_name = "SlamStart";
}

I then try to register my completed decision task with the following:

$result = $client->respondDecisionTaskCompleted(array(
    "taskToken" => $task_token,
    "decisions" => array(
        "decisionType" => "ScheduleActivityTask",
        "scheduleActivityTaskDecisionAttributes" => array(
            "activityType" => array(
                "name" => $activity_type_name,
                "version" => $activity_type_version
            ),
            "activityId" => "1",
            "control" => "something",
            "scheduleToCloseTimeout" => "300",
            "scheduleToStartTimeout" => "300",
            "startToCloseTimeout" => "300",
            "heartbeatTimeout" => "300",
            "taskList" => array(
                "name" => "mainTaskList"
            ),
            "input" => "test input"
        )
    )
));

echo "respondDecisionTaskCompleted call went through";

The above never goes through and the last line with echo is never reached.

Why is this happening?


Solution

  • The decisions property has one array wrapped inside of a second array. Instead of

    "decisions" => array(
        "decisionType" => "ScheduleActivityTask",
        "scheduleActivityTaskDecisionAttributes" => array(
            "activityType" => array(
                "name" => $activity_type_name,
                "version" => $activity_type_version
            ),
            "activityId" => "1",
            "control" => "something",
            "scheduleToCloseTimeout" => "300",
            "scheduleToStartTimeout" => "300",
            "startToCloseTimeout" => "300",
            "heartbeatTimeout" => "300",
            "taskList" => array(
                "name" => "mainTaskList"
            ),
            "input" => "test input"
        )
    )
    

    Had to change it to:

    "decisions" => array(
        array(
            "decisionType" => "ScheduleActivityTask",
            "scheduleActivityTaskDecisionAttributes" => array(
                "activityType" => array(
                    "name" => $activity_type_name,
                    "version" => $activity_type_version
                ),
                "activityId" => "1",
                "control" => "something",
                "scheduleToCloseTimeout" => "300",
                "scheduleToStartTimeout" => "300",
                "startToCloseTimeout" => "300",
                "heartbeatTimeout" => "300",
                "taskList" => array(
                    "name" => "mainTaskList"
                ),
                "input" => "test input"
            )
        )
    )