Jbpm并发子流程又一解决方案
关键字: JBPM 开源工作流引擎专栏并发子流程一直是困扰Jbpm爱好者的一大难题,JeffreyHsu 曾给出一个通过循环fork的解决方案(http://www.javaeye.com/article/29917),实际上jbpm也可以使用挂接action的方式生成子流程,所有生成的子流程都由同一个rootTooken下的childrenTooken来维护
流程定义如下
- xml version="1.0" encoding="UTF-8"?>
- <process-definition xmlns="" name="主流程">
- <start-state name="开始节点">
- <transition name="fork" to="fork">transition>
- start-state>
- <fork name="fork">
- <transition name="子流程分派" to="子流程分派节点">transition>
- fork>
- <state name="子流程分派节点">
- <transition name="结束所有子流程" to="结束所有子流程处理节点">transition>
- <transition name="子流程" to="子流程">
- <transition name="增加子流程" to="子流程分派节点">
- <action name="创建子流程" class="createSubProcess">
- <leavename>子流程名称leavename>
- action>
- transition>
- state>
- <process-state name="子流程">
- <sub-process name="子流程名称" />
- <transition name="" to="join">
- transition>
- process-state>
- <node name="结束所有子流程处理节点">
- <event type="node-enter">
- <action name="结束所有子流程" class="killAllSubProcess" />
- event>
- <transition to="join"/>
- node>
- <join name="join">
- <transition to="end">transition>
- join>
- <end-state name="end">end-state>
- process-definition>
class killAllSubProcess implements ActionHandler {
public void execute(ExecutionContext executionContext) throws Exception {
int i = 0;
Map m = executionContext.getProcessInstance().getRootToken().getActiveChildren();
Iterator iter = m.values().iterator();
while( iter.hasNext() ) {
Token t = (Token)iter.next();
if( t.getSubProcessInstance()!=null) {
t.getSubProcessInstance().end();
i++;
}
}
} }
class createSubProcess implements ActionHandler {
String leavename;
public void execute(ExecutionContext executionContext) throws Exception {
Token childToken = new Token( executionContext.getToken(), "TK" + ((new Random()).nextInt()) );
ExecutionContext newctx = new ExecutionContext(childToken);
executionContext.getTransitionSource().leave(newctx, leavename );
}
}
评论
<property name="mappingLocations">
<value>classpath*:/org/jbpm/**/*.hbm.xml</value>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle9Dialect
</prop>
<prop key="jdbc.fetch_size">50</prop>
<prop key="jdbc.batch_size">30</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.use_outer_join">true</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">
true
</prop>
</props>
</property>
以上是意思,能否请解一下。谢谢







评论排行榜