Search in sources :

Example 1 with WorkflowServiceException

use of com.uber.cadence.client.WorkflowServiceException in project cadence-client by uber-java.

the class WorkflowStubImpl method query.

@Override
public <R> R query(String queryType, Class<R> returnType, Object... args) {
    checkStarted();
    QueryWorkflowParameters p = new QueryWorkflowParameters();
    p.setInput(dataConverter.toData(args));
    p.setQueryType(queryType);
    p.setWorkflowId(execution.get().getWorkflowId());
    try {
        byte[] result = genericClient.queryWorkflow(p);
        return dataConverter.fromData(result, returnType);
    } catch (RuntimeException e) {
        Exception unwrapped = CheckedExceptionWrapper.unwrap(e);
        if (unwrapped instanceof EntityNotExistsError) {
            throw new WorkflowNotFoundException(execution.get(), workflowType, e.getMessage());
        }
        if (unwrapped instanceof QueryFailedError) {
            throw new WorkflowQueryException(execution.get(), unwrapped.getMessage());
        }
        if (unwrapped instanceof InternalServiceError) {
            throw new WorkflowServiceException(execution.get(), workflowType, unwrapped);
        }
        throw e;
    }
}
Also used : WorkflowNotFoundException(com.uber.cadence.client.WorkflowNotFoundException) InternalServiceError(com.uber.cadence.InternalServiceError) EntityNotExistsError(com.uber.cadence.EntityNotExistsError) QueryFailedError(com.uber.cadence.QueryFailedError) QueryWorkflowParameters(com.uber.cadence.internal.replay.QueryWorkflowParameters) 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) WorkflowQueryException(com.uber.cadence.client.WorkflowQueryException) WorkflowServiceException(com.uber.cadence.client.WorkflowServiceException)

Example 2 with WorkflowServiceException

use of com.uber.cadence.client.WorkflowServiceException 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 3 with WorkflowServiceException

use of com.uber.cadence.client.WorkflowServiceException 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();
}
Also used : DuplicateWorkflowException(com.uber.cadence.client.DuplicateWorkflowException) WorkflowType(com.uber.cadence.WorkflowType) WorkflowExecutionAlreadyStartedError(com.uber.cadence.WorkflowExecutionAlreadyStartedError) StartWorkflowExecutionParameters(com.uber.cadence.internal.common.StartWorkflowExecutionParameters) WorkflowExecution(com.uber.cadence.WorkflowExecution) 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)

Aggregations

DuplicateWorkflowException (com.uber.cadence.client.DuplicateWorkflowException)3 WorkflowException (com.uber.cadence.client.WorkflowException)3 WorkflowFailureException (com.uber.cadence.client.WorkflowFailureException)3 WorkflowNotFoundException (com.uber.cadence.client.WorkflowNotFoundException)3 WorkflowQueryException (com.uber.cadence.client.WorkflowQueryException)3 WorkflowServiceException (com.uber.cadence.client.WorkflowServiceException)3 WorkflowExecutionFailedException (com.uber.cadence.internal.common.WorkflowExecutionFailedException)3 CancellationException (java.util.concurrent.CancellationException)3 CompletionException (java.util.concurrent.CompletionException)3 TimeoutException (java.util.concurrent.TimeoutException)3 EntityNotExistsError (com.uber.cadence.EntityNotExistsError)1 InternalServiceError (com.uber.cadence.InternalServiceError)1 QueryFailedError (com.uber.cadence.QueryFailedError)1 WorkflowExecution (com.uber.cadence.WorkflowExecution)1 WorkflowExecutionAlreadyStartedError (com.uber.cadence.WorkflowExecutionAlreadyStartedError)1 WorkflowType (com.uber.cadence.WorkflowType)1 StartWorkflowExecutionParameters (com.uber.cadence.internal.common.StartWorkflowExecutionParameters)1 QueryWorkflowParameters (com.uber.cadence.internal.replay.QueryWorkflowParameters)1 SignalExternalWorkflowParameters (com.uber.cadence.internal.replay.SignalExternalWorkflowParameters)1