use of com.uber.cadence.internal.common.StartWorkflowExecutionParameters in project cadence-client by uber-java.
the class WorkflowStubImpl method startWithOptions.
private WorkflowExecution startWithOptions(WorkflowOptions o, Object... args) {
if (execution.get() != null) {
throw new DuplicateWorkflowException(execution.get(), workflowType.get(), "Cannot reuse a stub instance to start more than one workflow execution. The stub " + "points to already started execution.");
}
StartWorkflowExecutionParameters p = new StartWorkflowExecutionParameters();
p.setTaskStartToCloseTimeoutSeconds(o.getTaskStartToCloseTimeout().getSeconds());
if (o.getWorkflowId() == null) {
p.setWorkflowId(UUID.randomUUID().toString());
} else {
p.setWorkflowId(o.getWorkflowId());
}
p.setExecutionStartToCloseTimeoutSeconds(o.getExecutionStartToCloseTimeout().getSeconds());
p.setInput(dataConverter.toData(args));
p.setWorkflowType(new WorkflowType().setName(workflowType.get()));
p.setTaskList(o.getTaskList());
p.setChildPolicy(o.getChildPolicy());
try {
execution.set(genericClient.startWorkflow(p));
} catch (WorkflowExecutionAlreadyStartedError e) {
execution.set(new WorkflowExecution().setWorkflowId(p.getWorkflowId()).setRunId(e.getRunId()));
WorkflowExecution execution = new WorkflowExecution().setWorkflowId(p.getWorkflowId()).setRunId(e.getRunId());
throw new DuplicateWorkflowException(execution, workflowType.get(), e.getMessage());
} catch (Exception e) {
throw new WorkflowServiceException(execution.get(), workflowType, e);
}
return execution.get();
}
Aggregations