AWS Simple Workflow - respondDecisionTaskCompleted不工作?

时间:2014-12-08 20:48:39

标签: amazon-web-services amazon-swf aws-php-sdk

我目前正在使用PHP SDK for SWF。我使用以下方法成功完成决策任务:

$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";
}

然后我尝试使用以下内容注册我已完成的决策任务:

$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";

以上内容永远不会通过,永远不会到达echo的最后一行。

为什么会这样?

1 个答案:

答案 0 :(得分:1)

decisions属性在第二个数组中包含一个数组。而不是

"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"
    )
)

不得不改为:

"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"
        )
    )
)