rest api to start a process instance is holding request untill process instance is complete

cancel
Showing results for 
Search instead for 
Did you mean: 
Member II

rest api to start a process instance is holding request untill process instance is complete

Jump to solution

i am using activiti version 6.

i created a bpmn process from activiti-app

then i want to strart that process from activiti-rest.war using the api

http://localhost:8080/activiti-rest/service/runtime/process-instances‍‍‍‍
request body :

{
     
   "processDefinitionKey":"cep_dispatch_process",
   "businessKey":"myBusinessKey",
     "returnVariables": false
}

header :
Content-Type:application/json‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

as i see in the LOG process is being started in tomcat threads.

refering latest github code:

Activiti-activiti-6.0.0\modules\activiti-rest\src\main\java\org\activiti\rest\service\api\runtime\process\ProcessInstanceCollectionResource.java

when i see method

   

@RequestMapping(value = "/runtime/process-instances", method = RequestMethod.POST, produces = "application/json")
  public ProcessInstanceResponse createProcessInstance(@RequestBody ProcessInstanceCreateRequest request, HttpServletRequest httpRequest, HttpServletResponse response) {‍‍‍‍‍‍

 i can see process is being started  and not waiting for process to complete , http response is 201. i can understand request is not being hold for process instance to complete

 instance = processInstanceBuilder.start();

response.setStatus(HttpStatus.CREATED.value());‍‍‍‍‍‍‍‍‍

please refer the log snipped below, i can see process is executing in server thread and request is waiting till process completed

276-DEBUG 17-01-2019 14:12:07,177- (http-nio-8080-exec-3) ExecutionEntityManagerImpl: Child execution Execution[ id '130023' ] - parent '130021' created with parent 130021
241-DEBUG 17-01-2019 14:12:07,178- (http-nio-8080-exec-3) ContinueProcessOperation: Executing boundary event activityBehavior class org.activiti.engine.impl.bpmn.behavior.BoundaryTimerEventActivityBehavior with execution 130023
171-DEBUG 17-01-2019 14:12:07,202- (http-nio-8080-exec-3) ContinueProcessOperation: Executing activityBehavior class org.activiti.engine.impl.bpmn.behavior.SubProcessActivityBehavior on activity 'sid-1A2A8DF5-764A-4960-8E5D-F347DC10207C' with execution 130021
276-DEBUG 17-01-2019 14:12:07,203- (http-nio-8080-exec-3) ExecutionEntityManagerImpl: Child execution Execution[ id '130025' ] - parent '130021' created with parent 130021
63-DEBUG 17-01-2019 14:12:07,203- (http-nio-8080-exec-3) DefaultActivitiEngineAgenda: Operation class org.activiti.engine.impl.agenda.ContinueProcessOperation added to agenda
70-DEBUG 17-01-2019 14:12:07,203- (http-nio-8080-exec-3) CommandInvoker: Executing operation class org.activiti.engine.impl.agenda.ContinueProcessOperation ‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Please help request must not wait for process to complete .

how can i solve this, request to start the process must not wait for process-instance to complete.

as you see in the response below:

{
"id":"130028",
"url":"http://localhost:8080/activiti-rest/service/runtime/process-instances/130028",
"businessKey":"myBusinessKey",
"suspended":false,
"ended":true,
"processDefinitionId":"cep_dispatch_process:13:125033",
"processDefinitionUrl":"http://localhost:8080/activiti-rest/service/repository/process-definitions/cep_dispatch_process:13:125033",
"processDefinitionKey":"cep_dispatch_process",
"activityId":null,
"variables":[],
"tenantId":"",
"name":null,
"completed":true
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

api is returning only after process completes, i add delay of 2 min in service task , i can see request will be waiting. please help

1 Solution

Accepted Solutions
Member II

Re: rest api to start a process instance is holding request untill process instance is complete

Jump to solution
3 Replies
Member II

Re: rest api to start a process instance is holding request untill process instance is complete

Jump to solution
Active Member

Re: rest api to start a process instance is holding request untill process instance is complete

Jump to solution

Sorry, but I'm afraid that I'm not able to see the solution.

Active Member

Re: rest api to start a process instance is holding request untill process instance is complete

Jump to solution

Service tasks are synchronous as default. Try marking your service task as asynchronous to get an immediate response in the REST call.