Search in sources :

Example 1 with StartChildWorkflowExecutionParameters

use of com.uber.cadence.internal.replay.StartChildWorkflowExecutionParameters in project cadence-client by uber-java.

the class SyncDecisionContext method executeChildWorkflowOnce.

/**
 * @param executionResult promise that is set bu this method when child workflow is started.
 */
private Promise<byte[]> executeChildWorkflowOnce(String name, ChildWorkflowOptions options, byte[] input, CompletablePromise<WorkflowExecution> executionResult) {
    StartChildWorkflowExecutionParameters parameters = new StartChildWorkflowExecutionParameters.Builder().setWorkflowType(new WorkflowType().setName(name)).setWorkflowId(options.getWorkflowId()).setInput(input).setChildPolicy(options.getChildPolicy()).setExecutionStartToCloseTimeoutSeconds(options.getExecutionStartToCloseTimeout().getSeconds()).setDomain(options.getDomain()).setTaskList(options.getTaskList()).setTaskStartToCloseTimeoutSeconds(options.getTaskStartToCloseTimeout().getSeconds()).setWorkflowIdReusePolicy(options.getWorkflowIdReusePolicy()).build();
    CompletablePromise<byte[]> result = Workflow.newPromise();
    Consumer<Exception> cancellationCallback = context.startChildWorkflow(parameters, executionResult::complete, (output, failure) -> {
        if (failure != null) {
            runner.executeInWorkflowThread("child workflow failure callback", () -> result.completeExceptionally(mapChildWorkflowException(failure)));
        } else {
            runner.executeInWorkflowThread("child workflow completion callback", () -> result.complete(output));
        }
    });
    CancellationScope.current().getCancellationRequest().thenApply((reason) -> {
        cancellationCallback.accept(new CancellationException(reason));
        return null;
    });
    return result;
}
Also used : CancellationException(java.util.concurrent.CancellationException) WorkflowType(com.uber.cadence.WorkflowType) StartChildWorkflowExecutionParameters(com.uber.cadence.internal.replay.StartChildWorkflowExecutionParameters) ActivityTimeoutException(com.uber.cadence.workflow.ActivityTimeoutException) ChildWorkflowTaskFailedException(com.uber.cadence.internal.replay.ChildWorkflowTaskFailedException) ActivityTaskTimeoutException(com.uber.cadence.internal.replay.ActivityTaskTimeoutException) ActivityTaskFailedException(com.uber.cadence.internal.replay.ActivityTaskFailedException) ChildWorkflowFailureException(com.uber.cadence.workflow.ChildWorkflowFailureException) CancellationException(java.util.concurrent.CancellationException) ChildWorkflowException(com.uber.cadence.workflow.ChildWorkflowException) ActivityFailureException(com.uber.cadence.workflow.ActivityFailureException) SignalExternalWorkflowException(com.uber.cadence.workflow.SignalExternalWorkflowException) ActivityException(com.uber.cadence.workflow.ActivityException)

Aggregations

WorkflowType (com.uber.cadence.WorkflowType)1 ActivityTaskFailedException (com.uber.cadence.internal.replay.ActivityTaskFailedException)1 ActivityTaskTimeoutException (com.uber.cadence.internal.replay.ActivityTaskTimeoutException)1 ChildWorkflowTaskFailedException (com.uber.cadence.internal.replay.ChildWorkflowTaskFailedException)1 StartChildWorkflowExecutionParameters (com.uber.cadence.internal.replay.StartChildWorkflowExecutionParameters)1 ActivityException (com.uber.cadence.workflow.ActivityException)1 ActivityFailureException (com.uber.cadence.workflow.ActivityFailureException)1 ActivityTimeoutException (com.uber.cadence.workflow.ActivityTimeoutException)1 ChildWorkflowException (com.uber.cadence.workflow.ChildWorkflowException)1 ChildWorkflowFailureException (com.uber.cadence.workflow.ChildWorkflowFailureException)1 SignalExternalWorkflowException (com.uber.cadence.workflow.SignalExternalWorkflowException)1 CancellationException (java.util.concurrent.CancellationException)1