Search in sources :

Example 1 with ExecuteActivityParameters

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

the class SyncDecisionContext method executeActivityOnce.

private Promise<byte[]> executeActivityOnce(String name, ActivityOptions options, byte[] input) {
    CompletablePromise<byte[]> result = Workflow.newPromise();
    ExecuteActivityParameters parameters = new ExecuteActivityParameters();
    // TODO: Real task list
    String taskList = options.getTaskList();
    if (taskList == null) {
        taskList = context.getTaskList();
    }
    parameters.withActivityType(new ActivityType().setName(name)).withInput(input).withTaskList(taskList).withScheduleToStartTimeoutSeconds(options.getScheduleToStartTimeout().getSeconds()).withStartToCloseTimeoutSeconds(options.getStartToCloseTimeout().getSeconds()).withScheduleToCloseTimeoutSeconds(options.getScheduleToCloseTimeout().getSeconds()).setHeartbeatTimeoutSeconds(options.getHeartbeatTimeout().getSeconds());
    Consumer<Exception> cancellationCallback = context.scheduleActivityTask(parameters, (output, failure) -> {
        if (failure != null) {
            runner.executeInWorkflowThread("activity failure callback", () -> result.completeExceptionally(mapActivityException(failure)));
        } else {
            runner.executeInWorkflowThread("activity completion callback", () -> result.complete(output));
        }
    });
    CancellationScope.current().getCancellationRequest().thenApply((reason) -> {
        cancellationCallback.accept(new CancellationException(reason));
        return null;
    });
    return result;
}
Also used : ExecuteActivityParameters(com.uber.cadence.internal.replay.ExecuteActivityParameters) CancellationException(java.util.concurrent.CancellationException) ActivityType(com.uber.cadence.ActivityType) 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

ActivityType (com.uber.cadence.ActivityType)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 ExecuteActivityParameters (com.uber.cadence.internal.replay.ExecuteActivityParameters)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