-
1. Re: Workflow transaction boundary
swiderski.maciej Oct 15, 2014 1:37 AM (in response to partha.pal)this is most likely caused by persistence context not able to find entities created/updated in single transaction due to flush mode set to COMMIT on entity manager.
Although the use case you showed looks weird to me. Since you have a user task how is that possible to do the completion of the task directly when it was created - without user interaction? If it's not user that should work on a task consider to use another type of task like service task or domain specific task.
HTH
-
2. Re: Workflow transaction boundary
partha.pal Oct 15, 2014 1:56 AM (in response to swiderski.maciej)Thanks for the reply Maciej, Here is the actual code
@Transactional
public ITaskResponse submitForApproval(String businesskey, String group,
String user,
String approver) throws WorkflowException {
long pid;
if (isWorkflowRunning(businesskey)) {pid = getProcessInstanceId(businesskey);
} else if (isWorkflowNew(businesskey)) {
pid = getEngine().startBusinessProcess(getBPMNProcessId(), null);
} else {
throw new WorkflowException("Workflow instance for " +
businesskey + " already exists");
}
completeTask(WorkflowConstant.TASK_SUBMIT, pid, user, group,
null);
}To complete the very first task of the workflow, I need to start the flow and complete the task in a single transactional block so that in case of any issue everything will be rolled back. completeTask method uses LocalTaskService to start and complete the task. How to do these in single transaction?
-
3. Re: Workflow transaction boundary
partha.pal Dec 3, 2014 7:47 AM (in response to partha.pal)I found the answer. I've used request scoped session strategy. Inside the same transaction, if more than one different sessions involved, then it did not work properly. Then I aligned the session with transaction and now it is working properly.