提交 fc4837db 编写于 作者: J Joram Barrez

Fixing async gateway test. With a serious change in the way optimistic locking handled

上级 665db2a0
......@@ -61,7 +61,12 @@ public class ExecuteAsyncRunnable implements Runnable {
optimisticLockingException.getMessage());
}
commandExecutor.execute(new Command<Void>() {
public Void execute(CommandContext commandContext) {
commandContext.getJobEntityManager().retryAsyncJob(job);
return null;
}
});
return;
} catch (Throwable t) {
......
......@@ -23,6 +23,7 @@ import java.util.List;
import java.util.Map;
import org.activiti.engine.ActivitiObjectNotFoundException;
import org.activiti.engine.ActivitiOptimisticLockingException;
import org.activiti.engine.delegate.event.ActivitiEventType;
import org.activiti.engine.delegate.event.impl.ActivitiEventBuilder;
import org.activiti.engine.impl.ExecutionQueryImpl;
......@@ -223,22 +224,6 @@ public class ExecutionEntityManager extends AbstractEntityManager<ExecutionEntit
getDbSqlSession().update("updateExecutionTenantIdForDeployment", params);
}
public void updateProcessInstanceLockTime(String processInstanceId) {
CommandContext commandContext = Context.getCommandContext();
Date expirationTime = commandContext.getProcessEngineConfiguration().getClock().getCurrentTime();
int lockMillis = commandContext.getProcessEngineConfiguration().getAsyncExecutor().getAsyncJobLockTimeInMillis();
GregorianCalendar lockCal = new GregorianCalendar();
lockCal.setTime(expirationTime);
lockCal.add(Calendar.MILLISECOND, lockMillis);
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("id", processInstanceId);
params.put("lockTime", lockCal.getTime());
params.put("expirationTime", expirationTime);
getDbSqlSession().update("updateProcessInstanceLockTime", params);
}
// DELETE METHODS
......@@ -294,6 +279,25 @@ public class ExecutionEntityManager extends AbstractEntityManager<ExecutionEntit
// OTHER METHODS
public void updateProcessInstanceLockTime(String processInstanceId) {
CommandContext commandContext = Context.getCommandContext();
Date expirationTime = commandContext.getProcessEngineConfiguration().getClock().getCurrentTime();
int lockMillis = commandContext.getProcessEngineConfiguration().getAsyncExecutor().getAsyncJobLockTimeInMillis();
GregorianCalendar lockCal = new GregorianCalendar();
lockCal.setTime(expirationTime);
lockCal.add(Calendar.MILLISECOND, lockMillis);
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("id", processInstanceId);
params.put("lockTime", lockCal.getTime());
params.put("expirationTime", expirationTime);
int result = getDbSqlSession().update("updateProcessInstanceLockTime", params);
if (result == 0) {
throw new ActivitiOptimisticLockingException("JORAM123");
}
}
public void clearProcessInstanceLockTime(String processInstanceId) {
HashMap<String, Object> params = new HashMap<String, Object>();
......
......@@ -433,7 +433,7 @@ public class InclusiveGatewayTest extends PluggableActivitiTestCase {
@Deployment
public void testAsyncBehavior() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("async");
waitForJobExecutorToProcessAllJobs(500000000L, 5000L);
waitForJobExecutorToProcessAllJobs(5000L, 250);
assertEquals(0, runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).count());
}
......
......@@ -18,7 +18,7 @@
<sequenceFlow id="flow2" sourceRef="fork" targetRef="task1" />
<sequenceFlow id="flow3" sourceRef="fork" targetRef="task2" />
<inclusiveGateway id="join" activiti:async="true" />
<inclusiveGateway id="join" activiti:async="true" activiti:exclusive="true" />
<sequenceFlow id="flow4" sourceRef="task1" targetRef="join" />
<sequenceFlow id="flow5" sourceRef="task2" targetRef="join" />
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册