in src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/GenericWorkflowClientImpl.java [144:198]
public Promise<StartChildWorkflowReply> startChildWorkflow(final StartChildWorkflowExecutionParameters parameters) {
final OpenRequestInfo<StartChildWorkflowReply, WorkflowType> context = new OpenRequestInfo<StartChildWorkflowReply, WorkflowType>();
String workflowId = parameters.getWorkflowId();
if (workflowId == null) {
workflowId = generateUniqueId();
}
StartChildWorkflowExecutionDecisionAttributes.Builder attributesBuilder = StartChildWorkflowExecutionDecisionAttributes.builder()
.workflowType(parameters.getWorkflowType().toSdkType())
.workflowId(workflowId)
.input(parameters.getInput())
.executionStartToCloseTimeout(FlowHelpers.secondsToDuration(parameters.getExecutionStartToCloseTimeoutSeconds()))
.taskStartToCloseTimeout(FlowHelpers.secondsToDuration(parameters.getTaskStartToCloseTimeoutSeconds()))
.taskPriority(FlowHelpers.taskPriorityToString(parameters.getTaskPriority()))
.lambdaRole(parameters.getLambdaRole());
List<String> tagList = parameters.getTagList();
if (tagList != null) {
attributesBuilder.tagList(tagList);
}
ChildPolicy childPolicy = parameters.getChildPolicy();
if (childPolicy != null) {
attributesBuilder.childPolicy(childPolicy);
}
String taskList = parameters.getTaskList();
if (taskList != null && !taskList.isEmpty()) {
attributesBuilder.taskList(TaskList.builder().name(taskList).build());
}
final StartChildWorkflowExecutionDecisionAttributes attributes = attributesBuilder.build();
String taskName = "workflowId=" + workflowId + ", workflowType=" + attributes.workflowId();
new ExternalTask() {
@Override
protected ExternalTaskCancellationHandler doExecute(final ExternalTaskCompletionHandle handle) throws Throwable {
context.setCompletionHandle(handle);
String workflowId = attributes.workflowId();
if (scheduledExternalWorkflows.containsKey(decisions.getActualChildWorkflowId(workflowId))) {
WorkflowExecution workflowExecution = WorkflowExecution.builder().workflowId(workflowId).build();
WorkflowType workflowType = fromSdkType(attributes.workflowType());
long fakeEventId = -1;
handle.fail(new StartChildWorkflowFailedException(fakeEventId, workflowExecution, workflowType, StartChildWorkflowExecutionFailedCause.WORKFLOW_ALREADY_RUNNING.toString()));
return new ChildWorkflowCancellationHandler(workflowId, handle);
}
// should not update this map if the same work flow is running
decisions.startChildWorkflowExecution(attributes);
scheduledExternalWorkflows.put(workflowId, context);
return new ChildWorkflowCancellationHandler(workflowId, handle);
}
}.setName(taskName);
context.setResultDescription("startChildWorkflow " + taskName);
return context.getResult();
}