Activiti Timer Start Event

12月 22, 2015 |

确保processEngineConfiguration.jobExecutorActivate=true或者没有配置,因为这个配置项的默认值为true
将开始事件转换为Timer Start Event。本例使用使用timeCycle配置一分钟执行一次,共四次,本例也添加了一个executionListener来捕获该事件

<startEvent id="timerstartevent1" name="Start">
<extensionElements>
<activiti:executionListener event="start" class="cn.javacoder.test.activiti.MyListener"></activiti:executionListener>
</extensionElements>
<timerEventDefinition>
<timeCycle>R4/PT1M</timeCycle>
</timerEventDefinition>
</startEvent>

当然我们也可以配置自己的JobExecutor,如下:

<!-- spring task executor -->
<bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<property name="maxPoolSize" value="5"/>
<property name="keepAliveSeconds" value="30" />
</bean>
<bean id="jobExecutor" class="org.activiti.spring.SpringJobExecutor">
<constructor-arg ref="taskExecutor"/>
</bean>
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
<......>
<property name="jobExecutorActivate" value="true" />
<property name="jobExecutor" ref="jobExecutor" />
</bean>

5.17.0版本引入了AsyncExecutor,和原来的JobExecutor最大的区别是一次查询出多个带执行的job,减少数据库的操作,当这个job是排他的(exclusive),会锁住整个流程实例(process instance),配置可以参考User Guide.

参考文档:

1、Activiti User Guide

Posted in: Activiti

Comments are closed.