use of com.uber.cadence.WorkflowQuery in project cadence-client by uber-java.
the class WorkflowWorker method queryWorkflowExecution.
public byte[] queryWorkflowExecution(WorkflowExecution execution, String queryType, byte[] args) throws Exception {
Iterator<HistoryEvent> history = WorkflowExecutionUtils.getHistory(service, domain, execution);
DecisionTaskWithHistoryIterator historyIterator = new ReplayDecisionTaskWithHistoryIterator(execution, history);
WorkflowQuery query = new WorkflowQuery();
query.setQueryType(queryType).setQueryArgs(args);
historyIterator.getDecisionTask().setQuery(query);
DecisionTaskHandler.Result result = handler.handleDecisionTask(historyIterator);
if (result.getQueryCompleted() != null) {
RespondQueryTaskCompletedRequest r = result.getQueryCompleted();
return r.getQueryResult();
}
throw new RuntimeException("Query returned wrong response: " + result);
}
use of com.uber.cadence.WorkflowQuery in project cadence-client by uber-java.
the class GenericWorkflowClientExternalImpl method queryWorkflow.
@Override
public byte[] queryWorkflow(QueryWorkflowParameters queryParameters) {
QueryWorkflowRequest request = new QueryWorkflowRequest();
request.setDomain(domain);
WorkflowExecution execution = new WorkflowExecution();
execution.setWorkflowId(queryParameters.getWorkflowId()).setRunId(queryParameters.getRunId());
request.setExecution(execution);
WorkflowQuery query = new WorkflowQuery();
query.setQueryArgs(queryParameters.getInput());
query.setQueryType(queryParameters.getQueryType());
request.setQuery(query);
try {
QueryWorkflowResponse response = service.QueryWorkflow(request);
return response.getQueryResult();
} catch (TException e) {
throw CheckedExceptionWrapper.wrap(e);
}
}
Aggregations