in src/main/java/com/uber/cadence/serviceclient/WorkflowServiceTChannel.java [2197:2263]
private void startWorkflowExecution(
StartWorkflowExecutionRequest startRequest,
AsyncMethodCallback resultHandler,
Long timeoutInMillis) {
startRequest.setRequestId(UUID.randomUUID().toString());
timeoutInMillis = validateAndUpdateTimeout(timeoutInMillis, options.getRpcTimeoutMillis());
ThriftRequest<WorkflowService.StartWorkflowExecution_args> request =
buildThriftRequest(
"StartWorkflowExecution",
new WorkflowService.StartWorkflowExecution_args(startRequest),
timeoutInMillis);
CompletableFuture<ThriftResponse<WorkflowService.StartWorkflowExecution_result>> response =
doRemoteCallAsync(request);
response
.whenComplete(
(r, e) -> {
try {
if (e != null) {
resultHandler.onError(CheckedExceptionWrapper.wrap(e));
return;
}
WorkflowService.StartWorkflowExecution_result result =
r.getBody(WorkflowService.StartWorkflowExecution_result.class);
if (r.getResponseCode() == ResponseCode.OK) {
resultHandler.onComplete(result.getSuccess());
return;
}
if (result.isSetBadRequestError()) {
resultHandler.onError(result.getBadRequestError());
return;
}
if (result.isSetSessionAlreadyExistError()) {
resultHandler.onError(result.getSessionAlreadyExistError());
return;
}
if (result.isSetServiceBusyError()) {
resultHandler.onError(result.getServiceBusyError());
return;
}
if (result.isSetDomainNotActiveError()) {
resultHandler.onError(result.getDomainNotActiveError());
return;
}
if (result.isSetLimitExceededError()) {
resultHandler.onError(result.getLimitExceededError());
return;
}
if (result.isSetEntityNotExistError()) {
resultHandler.onError(result.getEntityNotExistError());
return;
}
resultHandler.onError(
new TException("StartWorkflowExecution failed with unknown error:" + result));
} finally {
if (r != null) {
r.release();
}
}
})
.exceptionally(
(e) -> {
log.error("Unexpected error in StartWorkflowExecution", e);
return null;
});
}