private ProcessInstance executeServiceProcess ( ProcessExecutor engine , Long processId , String ownerType , Long ownerId , String masterRequestId , Map < String , String > parameters , String secondaryOwnerType , Long secondaryOwnerId , Map < String , String > headers ) throws Exception { Process procdef = getProcessDefinition ( processId ) ; Long startActivityId = procdef . getStartActivity ( ) . getId ( ) ; if ( masterRequestId == null ) masterRequestId = genMasterRequestId ( ) ; ProcessInstance mainProcessInst = engine . createProcessInstance ( processId , ownerType , ownerId , secondaryOwnerType , secondaryOwnerId , masterRequestId , parameters ) ; mainProcessInstanceId = mainProcessInst . getId ( ) ; engine . updateProcessInstanceStatus ( mainProcessInst . getId ( ) , WorkStatus . STATUS_PENDING_PROCESS ) ; if ( OwnerType . DOCUMENT . equals ( ownerType ) && ownerId != 0L ) { setOwnerDocumentProcessInstanceId ( engine , ownerId , mainProcessInst . getId ( ) , masterRequestId ) ; bindRequestVariable ( procdef , ownerId , engine , mainProcessInst ) ; } if ( headers != null ) { bindRequestHeadersVariable ( procdef , headers , engine , mainProcessInst ) ; } logger . info ( logtag ( processId , mainProcessInst . getId ( ) , masterRequestId ) , WorkStatus . LOGMSG_PROC_START + " - " + procdef . getQualifiedName ( ) + "/" + procdef . getVersionString ( ) ) ; engine . notifyMonitors ( mainProcessInst , WorkStatus . LOGMSG_PROC_START ) ; // setProcessInstanceStatus will really set to STATUS_IN_PROGRESS - hint to set START_DT as well InternalEvent event = InternalEvent . createActivityStartMessage ( startActivityId , mainProcessInst . getId ( ) , 0L , masterRequestId , EventType . EVENTNAME_START ) ; InternalMessenger msgBroker = engine . getInternalMessenger ( ) ; lastException = null ; processEvent ( engine , event , mainProcessInst ) ; while ( ( event = msgBroker . getNextMessageFromQueue ( engine ) ) != null ) { ProcessInstance procInst = this . findProcessInstance ( engine , event ) ; processEvent ( engine , event , procInst ) ; } mainProcessInst = engine . getProcessInstance ( mainProcessInst . getId ( ) ) ; return mainProcessInst ; }
execute service process using asynch engine