Springboot 2.0 for asynch execution

Hi,
We are building flowable process with bunch of service tasks in Spring boot 2.0 Setup

Following is how I trigger runtimeService. It gets called through Restful POST request.

if (AppUtil.checkFile(processInput.getInputFile())) {
Map<String, Object> paramMap = AppUtil.buildParamMap(processInput);
ProcessInstance instance =
runtimeService.startProcessInstanceByKey(AppConstants.PROCESS_KEY, paramMap);
log.info(“ActivityId:” + instance.getActivityId());
return instance.getProcessInstanceId();
}

I noticed that process flow is synchronous . The Restful POST call is taking good 40-50 secs to complete the flow and then return back processInstance Id. I worry that in PROD environment the request will get timed out .

Is it possible to return back the instance.getProcessInstanceId() right away and then carry through the flow executing individual sequential service tasks ? If so where and what changes are needed in Springboot 2.0 setup ?

Thanks for the help.

runtimeService.startProcessInstanceByKey() starts the process synchronously up to the first wait state in your process. For it to be taking this long, you must have a service task that takes some time as your first task. If you mark it as async in the process, it will create a job and return right away. At some future point the async executor will pick it up and run it.

Thankyou wwitt. I tagged first service task with flowable:async=“true” and it behaved as suggested. I am yet to test if it has impacted overall job flow but the start definitley looks promising. Appreciate your quick response.

@sd2040,

There is also startAsync() on the ProcessInstanceBuilder:

 ProcessInstance someProcessInstance = runtimeService.createProcessInstanceBuilder().processDefinitionKey("someProcess").variables(vars).startAsync();

Thanks wwitt, the earlier solution worked for us.