关于JBPM4.4无法删除历史数据的问题
关于JBPM4.4无法删除历史数据的问题
JBPM无疑是业界最好的开源工作流引擎,但是从4.0到4.4这几个版本使用过来,还是存在不少的bug。
由于为了解决fork join节点的汇聚条件设置的bug,我们升级到了4.4,但是同时发现出现另外的问题,就是在删除一个已经关闭的流程时,会报错:Can't delete processInstance,no processInstance found for the given id。
这个问题在早期版本里不会出现。
看了下源码,原因是在关闭一个工单(流程结束)时,jbpm会自动调用deleteProcessInstance方法,删除jbpm_task表里的数据。
而此后再调用executionService.deleteProcessInstanceCascade()方法,按照源码的写法,显然是不成功的:
修改源码DbSessionImpl.java里的deleteProcessInstance方法即可:
view plaincopy01.public void deleteProcessInstance(String processInstanceId, boolean deleteHistory) {
02. if (processInstanceId == null) {
03. throw new JbpmException("processInstanceId is null");
04. }
05. // if history should be deleted
06. if (deleteHistory && (isHistoryEnabled())) {
07. // try to get the history
08. HistoryProcessInstanceImpl historyProcessInstance = findHistoryProcessInstanceById(processInstanceId);
09. // if there is a history process instance in the db
10. if (historyProcessInstance != null) {
11. if (log.isDebugEnabled()) {
12. log.debug("deleting history process instance " + processInstanceId);
13. }
14. session.delete(historyProcessInstance);
15. }
16. <span style="color:#FF6666;"><span style="background-color: rgb(255, 255, 255);">} else {</span></span>
17. ExecutionImpl processInstance = (ExecutionImpl) findProcessInstanceByIdIgnoreSuspended(processInstanceId);
18. if (processInstance != null) {
19. deleteSubProcesses(processInstance, deleteHistory);
20. // delete remaining tasks for this process instance
21. List<TaskImpl> tasks = findTasks(processInstanceId);
22. for (TaskImpl task : tasks) {
23. session.delete(task);
24. }
25. // delete remaining jobs for this process instance
26. JobImpl currentJob = EnvironmentImpl.getFromCurrent(JobImpl.class, false);
27. List<JobImpl> jobs = findJobs(processInstanceId);
28. for (JobImpl job : jobs) {
29. if (job != currentJob) {
30. session.delete(job);
31. }
32. }
33. if (log.isDebugEnabled()) {
34. log.debug("Deleting process instance " + processInstanceId);
35. }
36. session.delete(processInstance);
37. } else {
38. throw new JbpmException("Can't delete processInstance " + processInstanceId + ": no processInstance found for the given id");
39. }
40. <span style="color:#FF6666;">}</span>
41. } 谢谢分享
页:
[1]