【发布时间】:2015-07-28 23:21:32
【问题描述】:
我有 2 个应用程序在同一个数据库上运行。 他们都像这样启动activiti进程:
for (i = 0; i < msgNbr; i++) {
Map<String, Object> dataMap = Data.prepareData(testOptions);
runtimeService.startProcessInstanceByKey("asyncTransferProcess", dataMap);
}
正在启动的进程中的第一个服务任务是异步的:
<serviceTask id="serviceTask1" name="ServiceTask1" activiti:exclusive="true"
activiti:class="com.test.activiti.async.ServiceTask1"></serviceTask>
异步执行器配置:
<property name="asyncExecutor" ref="asyncExecutor" />
<property name="asyncExecutorEnabled" value="true" />
<property name="asyncExecutorActivate" value="true" />
<bean id="asyncExecutor" class="org.activiti.engine.impl.asyncexecutor.DefaultAsyncJobExecutor">
<property name="corePoolSize" value="20" />
<property name="maxPoolSize" value="50" />
<property name="keepAliveTime" value="3000" />
<property name="queueSize" value="200" />
<property name="maxTimerJobsPerAcquisition" value="2" />
<property name="maxAsyncJobsDuePerAcquisition" value="2" />
<property name="defaultAsyncJobAcquireWaitTimeInMillis" value="1000" />
<property name="defaultTimerJobAcquireWaitTimeInMillis" value="1000" />
<property name="timerLockTimeInMillis" value="60000" />
<property name="asyncJobLockTimeInMillis" value="60000" />
</bean>
问题是当应用程序尝试运行进程时我得到 ActivitiOptimisticLockingException 和 NullPointerException 导致两个应用程序可能尝试运行相同的作业。如果不注意异常,应用程序可以正常工作,但我想知道是否有任何提示如何在同一个数据库上运行具有异步进程的多个应用程序,并且可能有办法让应用程序只运行自己的作业?
【问题讨论】: