-
Notifications
You must be signed in to change notification settings - Fork 1
/
SecondStep.php
79 lines (72 loc) · 2.54 KB
/
SecondStep.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
require_once "path/to/aws.phar";
use Aws\Swf\SwfClient;
// Ask SWF for things the decider needs to know
$result = $client->pollForDecisionTask(array(
"domain" => "your domain name",
"taskList" => array(
"name" => "mainTaskList"
),
"identify" => "default",
"maximumPageSize" => 50,
"reverseOrder" => true
));
// Current version of activity types we are using
$activity_type_version = "1.0";
// Parse info we need returned from the pollForDecisionTask call
$task_token = $result["taskToken"];
$workflow_id = $result["workflowExecution"]["workflowId"];
$run_id = $result["workflowExecution"]["runId"];
$last_event = $result["events"][0]["eventId"];
// Our logic that decides what happens next
if($last_event == "3"){
$activity_type_name = "activity to start if last event ID was 3";
$task_list = "mainTaskList";
$activity_id = "1";
$continue_workflow = true;
}
elseif($last_event == "8"){
$activity_type_name = "activity to start if last event ID was 8";
$task_list = "mainTaskList";
$activity_id = "2";
$continue_workflow = false;
}
// Now that we populated our variables based on what we received from SWF, we need to tell SWF what we want to do next
if($continue_workflow === true){
$client->respondDecisionTaskCompleted(array(
"taskToken" => $task_token,
"decisions" => array(
array(
"decisionType" => "ScheduleActivityTask",
"scheduleActivityTaskDecisionAttributes" => array(
"activityType" => array(
"name" => $activity_type_name,
"version" => $activity_type_version
),
"activityId" => $activity_id,
"control" => "this is a sample message",
// Customize timeout values
"scheduleToCloseTimeout" => "360",
"scheduleToStartTimeout" => "300",
"startToCloseTimeout" => "60",
"heartbeatTimeout" => "60",
"taskList" => array(
"name" => $task_list
),
"input" => "this is a sample message"
)
)
)
));
}
// End workflow if last event ID was 8
else if($continue_workflow === false){
$client->respondDecisionTaskCompleted(array(
"taskToken" => $task_token,
"decisions" => array(
array(
"decisionType" => "CompleteWorkflowExecution"
)
)
));
}