Search in sources :

Example 1 with SignalExternalWorkflowParameters

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

the class WorkflowStubImpl method signal.

@Override
public void signal(String signalName, Object... input) {
    checkStarted();
    SignalExternalWorkflowParameters p = new SignalExternalWorkflowParameters();
    p.setInput(dataConverter.toData(input));
    p.setSignalName(signalName);
    p.setWorkflowId(execution.get().getWorkflowId());
    // p.setRunId(execution.getRunId());
    try {
        genericClient.signalWorkflowExecution(p);
    } catch (Exception e) {
        throw new WorkflowServiceException(execution.get(), workflowType, e);
    }
}
Also used : SignalExternalWorkflowParameters(com.uber.cadence.internal.replay.SignalExternalWorkflowParameters) DuplicateWorkflowException(com.uber.cadence.client.DuplicateWorkflowException) TimeoutException(java.util.concurrent.TimeoutException) WorkflowFailureException(com.uber.cadence.client.WorkflowFailureException) WorkflowNotFoundException(com.uber.cadence.client.WorkflowNotFoundException) WorkflowQueryException(com.uber.cadence.client.WorkflowQueryException) WorkflowException(com.uber.cadence.client.WorkflowException) CancellationException(java.util.concurrent.CancellationException) CompletionException(java.util.concurrent.CompletionException) WorkflowExecutionFailedException(com.uber.cadence.internal.common.WorkflowExecutionFailedException) WorkflowServiceException(com.uber.cadence.client.WorkflowServiceException) WorkflowServiceException(com.uber.cadence.client.WorkflowServiceException)

Example 2 with SignalExternalWorkflowParameters

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

the class SyncDecisionContext method signalWorkflow.

Promise<Void> signalWorkflow(WorkflowExecution execution, String signalName, Object... args) {
    SignalExternalWorkflowParameters parameters = new SignalExternalWorkflowParameters();
    parameters.setSignalName(signalName);
    parameters.setWorkflowId(execution.getWorkflowId());
    parameters.setRunId(execution.getRunId());
    byte[] input = getDataConverter().toData(args);
    parameters.setInput(input);
    CompletablePromise<Void> result = Workflow.newPromise();
    Consumer<Exception> cancellationCallback = context.signalWorkflowExecution(parameters, (output, failure) -> {
        if (failure != null) {
            runner.executeInWorkflowThread("child workflow failure callback", () -> result.completeExceptionally(mapSignalWorkflowException(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) SignalExternalWorkflowParameters(com.uber.cadence.internal.replay.SignalExternalWorkflowParameters) 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)

Example 3 with SignalExternalWorkflowParameters

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

the class SyncDecisionContext method signalExternalWorkflow.

@Override
public Promise<Void> signalExternalWorkflow(WorkflowExecution execution, String signalName, Object[] args) {
    SignalExternalWorkflowParameters parameters = new SignalExternalWorkflowParameters();
    parameters.setSignalName(signalName);
    parameters.setWorkflowId(execution.getWorkflowId());
    parameters.setRunId(execution.getRunId());
    byte[] input = getDataConverter().toData(args);
    parameters.setInput(input);
    CompletablePromise<Void> result = Workflow.newPromise();
    Consumer<Exception> cancellationCallback = context.signalWorkflowExecution(parameters, (output, failure) -> {
        if (failure != null) {
            runner.executeInWorkflowThread("child workflow failure callback", () -> result.completeExceptionally(mapSignalWorkflowException(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) SignalExternalWorkflowParameters(com.uber.cadence.internal.replay.SignalExternalWorkflowParameters) ActivityTimeoutException(com.uber.cadence.workflow.ActivityTimeoutException) ActivityTaskTimeoutException(com.uber.cadence.internal.replay.ActivityTaskTimeoutException) ActivityTaskFailedException(com.uber.cadence.internal.replay.ActivityTaskFailedException) CancellationException(java.util.concurrent.CancellationException) SignalExternalWorkflowException(com.uber.cadence.workflow.SignalExternalWorkflowException) ChildWorkflowTaskFailedException(com.uber.cadence.internal.replay.ChildWorkflowTaskFailedException) ChildWorkflowFailureException(com.uber.cadence.workflow.ChildWorkflowFailureException) ChildWorkflowTimedOutException(com.uber.cadence.workflow.ChildWorkflowTimedOutException) ChildWorkflowException(com.uber.cadence.workflow.ChildWorkflowException) ActivityFailureException(com.uber.cadence.workflow.ActivityFailureException) ActivityException(com.uber.cadence.workflow.ActivityException)

Example 4 with SignalExternalWorkflowParameters

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

the class WorkflowStubImpl method getSignalExternalWorkflowParameters.

private SignalExternalWorkflowParameters getSignalExternalWorkflowParameters(String signalName, Object... input) {
    checkStarted();
    SignalExternalWorkflowParameters p = new SignalExternalWorkflowParameters();
    p.setInput(dataConverter.toData(input));
    p.setSignalName(signalName);
    p.setWorkflowId(execution.get().getWorkflowId());
    // p.setRunId(execution.getRunId());
    return p;
}
Also used : SignalExternalWorkflowParameters(com.uber.cadence.internal.replay.SignalExternalWorkflowParameters)

Aggregations

SignalExternalWorkflowParameters (com.uber.cadence.internal.replay.SignalExternalWorkflowParameters)4 CancellationException (java.util.concurrent.CancellationException)3 ActivityTaskFailedException (com.uber.cadence.internal.replay.ActivityTaskFailedException)2 ActivityTaskTimeoutException (com.uber.cadence.internal.replay.ActivityTaskTimeoutException)2 ChildWorkflowTaskFailedException (com.uber.cadence.internal.replay.ChildWorkflowTaskFailedException)2 ActivityException (com.uber.cadence.workflow.ActivityException)2 ActivityFailureException (com.uber.cadence.workflow.ActivityFailureException)2 ActivityTimeoutException (com.uber.cadence.workflow.ActivityTimeoutException)2 ChildWorkflowException (com.uber.cadence.workflow.ChildWorkflowException)2 ChildWorkflowFailureException (com.uber.cadence.workflow.ChildWorkflowFailureException)2 SignalExternalWorkflowException (com.uber.cadence.workflow.SignalExternalWorkflowException)2 DuplicateWorkflowException (com.uber.cadence.client.DuplicateWorkflowException)1 WorkflowException (com.uber.cadence.client.WorkflowException)1 WorkflowFailureException (com.uber.cadence.client.WorkflowFailureException)1 WorkflowNotFoundException (com.uber.cadence.client.WorkflowNotFoundException)1 WorkflowQueryException (com.uber.cadence.client.WorkflowQueryException)1 WorkflowServiceException (com.uber.cadence.client.WorkflowServiceException)1 WorkflowExecutionFailedException (com.uber.cadence.internal.common.WorkflowExecutionFailedException)1 ChildWorkflowTimedOutException (com.uber.cadence.workflow.ChildWorkflowTimedOutException)1 CompletionException (java.util.concurrent.CompletionException)1