JBPM 4.3 调用executionService.signalExecutionById之后并没有走到下一个state

JBPM 4.3 调用executionService.signalExecutionById之后并没有走到下一个state

问题描述:

我最近刚刚学习JBPM 4.3, 照着xyz20003的用户指南写了一个小的列子,如下:

 

 

processInstance = executionService.startProcessInstanceByKey("abcdefg",variables);

Execution exec = processInstance.findActiveExecutionIn("state1");

executionService.signalExecutionById(exec.getId(), "to end1");

Assert.assertTrue(processInstance.isEnded());

 <process name="simplea" key ="abcdefg" xmlns="http://jbpm.org/4.3/jpdl">

   <start name="start1" g="280,48,48,48">
      <transition name="to state1" to="state1" g="-59,-17"/>
   </start>
   <end name="end1" g="272,261,48,48"/>
   <state name="state1" g="269,156,92,52">
      <transition name="to end1" to="end1" g="-47,-17"/>
   </state>
</process>

最终junit判断processInstance.isEnded() 为false;

然后我重新修改代码打印调试信息

 

 

 

processInstance = executionService.startProcessInstanceByKey("abcdefg",variables);

Execution exec = processInstance.findActiveExecutionIn("state1");

executionService.signalExecutionById(exec.getId(), "to end1");

Set<String> activityNames = processInstance.findActiveActivityNames();
if (activityNames == null) {
    System.out.println("current activityNames is null" );
}
else {
    for (String name: activityNames) {
    System.out.println("activity name is "+name);
        }
}

Assert.assertTrue(processInstance.isEnded());

打印了activity name is state1

 

我想问的是:

executionService.signalExecutionById(exec.getId(), "to end1"); 这个语句不是会让流程走到下面一个state吗,为何触发之后状态还是active,怎么样走到end节点或者说下一个节点呢?

 

对processInstance重新赋值就可以了

很不幸,我执行的是预期的结果。。。。。 :o :o :o

我用的是JBPM4.2执行通过,4.3我也试着执行了一下,执行失败,结果跟你的一样。

感觉是4.3未发现的新BUG。。。
因为看了升级文档,没有任何提示从STATE到END要有什么变化,

[code="java"]
Release Notes for jBPM 4.3

Main improvements

Added BPMN 2.0 runtime engine!
Extended java activity with ejb method invocation. JBPM-2412
Added jms activity (including test facilities) JBPM-2300
Added integrated rules deployment and activities rules and rules-decision JBPM-2006
Added enhanced spring integration and created continuous integration for it JBPM-2529 & JBPM-2631
Automatic saving of updated deserialized variables JBPM-2684
Added count() capabilities to all queries in the api JBPM-2567
Fixes various bugs
DB changes

No DB upgrade necessary for upgrading from 4.2 to 4.3

API changes

DeploymentQuery.PROPERTY_NAME has been removed due to errors when sorting on name on Oracle (was already deprecated in a previous release).
DeploymentQuery.deploymentDbId(long dbid) has been changed to DeploymentQuery.deploymentId(String id) to be conistent with the query API.
The behaviour of taskService.getOutcomes(taskId) have been changed. See issue [JBPM-2492].
jPDL changes

No backward incompatible changes
Added jms, rules and rules-decision activities
Added attribute ejb-jndi-name to java activity
Added attribute propagation to all event-listeners
Configuration changes

Spring integration: Creating a processEngine bean is now done through the org.jbpm.pvm.internal.processengine.SpringHelper class (instead of the SpringConfiguration class). See the Spring chapter in the developers guide for more information.
Known Limitation

Reporting in the jBPM console does not work on Tomcat. See [JBPM-2627]
Bug

[JBPM-2491] - Deleting a ProcessInstance having a running Sub-ProcessInstance fails
[JBPM-2492] - improve task outcomes
[JBPM-2529] - jBPM-Spring Integration doesn't work for EvenListener-s
[JBPM-2575] - event-listener propagation attribute not in jpdl-4.0.xsd
[JBPM-2577] - QuerySyntaxException in HistoryService
[JBPM-2618] - Source level problem running Ant script: /examples/build.xml
[JBPM-2628] - Calling executionService.startProcessInstanceByKey with a non-existent key throws an unhelful exception
[JBPM-2639] - Task with taskform and timer leads to NPE
[JBPM-2643] - adding tasks not belonging to an execution breaks the console
[JBPM-2649] - HistoryActivityInstanceQueryImpl references wrong property for processDefinitionId
[JBPM-2651] - Error on executing a process with sub processes
[JBPM-2654] - instal.jbpm.into.jboss does not copy the MySQL driver
[JBPM-2657] - No override of convenience methods in SpringConfiguration
[JBPM-2683] - Upgrade 4.1 to 4.2 Breaks subprocess - integrity constraint (JBPM_DEV.FK_EXEC_SUBPI) violated - child record found
Feature Request

[JBPM-2412] - extend java activity targets with ejb
[JBPM-2538] - Make a TaskQuery resuable
[JBPM-2558] - SpringTransactionInterceptor: Resolve transactionManager by name
[JBPM-2567] - TaskQuery Should allow to .count() Tasks in addition of .list() them
[JBPM-2576] - Extending HistorySession - add public getters in HistoryEvents
[JBPM-2661] - BPMN2: Exclusive gateway
[JBPM-2662] - BPMN2: parallel gateway
[JBPM-2663] - BPMN2: service task (Java based)
[JBPM-2664] - BPMN2: Manual task
[JBPM-2665] - BPMN2: receive task (java message only)
[JBPM-2666] - BPMN2: script task
[JBPM-2667] - BPMN2: User task
[JBPM-2668] - BPMN2: none start/end event
[JBPM-2669] - BPMN2: terminate end event
[JBPM-2670] - BPMN2: sequence flow
[JBPM-2671] - BPMN2: conditional sequence flow
[JBPM-2673] - BPMN2: Interface (basic: Java only)
[JBPM-2674] - BPMN2: resource
[JBPM-2675] - BPMN2: document 'getting started'
[JBPM-2676] - BPMN: default sequence flow
Task

[JBPM-2006] - drools integration
[JBPM-2300] - jms activity
[JBPM-2616] - clean up JpdlDeployer
[JBPM-2623] - remove duplicate inclusion of xsd docs in the distro
[JBPM-2631] - set up spring hudson job
[JBPM-2632] - move XPathScriptEngine classes from bpmn to pvm
[JBPM-2660] - BPMN2: create basic example and document it
[JBPM-2680] - core.jar creates exception in some nested deployment on jboss
[JBPM-2684] - automatic saving of updates to serializable variables
[JBPM-2695] - investigate user testibility of java ejb invoke activity and jms[/code]

其实是你的代码有问题
因为虽然你在开始的时候新建了一个变量
[code="java"]processInstance = executionService.startProcessInstanceByKey("abcdefg",variables); [/code]
但是这个processInstance并不会随着你的流程的执行自动改变

processInstance = executionService.startProcessInstanceByKey("abcdefg",variables);

Execution exec = processInstance.findActiveExecutionIn("state1");

processInstance =executionService.signalExecutionById(exec.getId(), "to end1");

Assert.assertTrue(processInstance.isEnded());

惭愧,惭愧,正如楼上所说,

没仔细看代码,不好意思, :wink: :wink: :wink: :wink: