use of com.uber.cadence.QueryFailedError in project cadence-client by uber-java.
the class TestWorkflowMutableStateImpl method completeQuery.
@Override
public void completeQuery(QueryId queryId, RespondQueryTaskCompletedRequest completeRequest) throws EntityNotExistsError {
CompletableFuture<QueryWorkflowResponse> result = queries.get(queryId.getQueryId());
if (result == null) {
throw new EntityNotExistsError("Unknown query id: " + queryId.getQueryId());
}
if (completeRequest.getCompletedType() == QueryTaskCompletedType.COMPLETED) {
QueryWorkflowResponse response = new QueryWorkflowResponse().setQueryResult(completeRequest.getQueryResult());
result.complete(response);
} else {
QueryFailedError error = new QueryFailedError().setMessage(completeRequest.getErrorMessage());
result.completeExceptionally(error);
}
}
use of com.uber.cadence.QueryFailedError 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;
}
}
Aggregations