01-20-2015 04:35 AM
public class AsyncProcessTest {
@Rule
public ActivitiRule activitiRule = new ActivitiRule("test.activiti.cfg.xml");
@Test
@Deployment(resources = {"AsyncFailProcess.bpmn20.xml"})
public void retryTakesProcessBackToUserTask() throws Exception {
ProcessInstance process = activitiRule.getRuntimeService().startProcessInstanceByKey("async_process");
completeAsyncJobs();
assertThat(process.getActivityId(), is("usertask1"));
TaskService taskService = activitiRule.getTaskService();
String taskId = taskService.createTaskQuery().executionId(process.getProcessInstanceId())
.singleResult().getId();
Map<String, Object> variables = new HashMap<>();
variables.put("action", "retry");
taskService.complete(taskId, variables);
completeAsyncJobs();
assertThat(process.getActivityId(), is("usertask1"));
}
private void completeAsyncJobs() {
//Complete async jobs
ManagementService managementService = activitiRule.getManagementService();
List<Job> jobs = managementService.createJobQuery().list();
for (Job job : jobs) {
managementService.executeJob(job.getId());
}
}
}
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
<process id="async_process" name="Async Process" isExecutable="true">
<startEvent id="startevent1" name="Start"></startEvent>
<serviceTask id="servicetask1" name="Async Service Task" activiti:async="true" activiti:class="com.asyncexample.NothingServiceTask"></serviceTask>
<userTask id="usertask1" name="User Task"></userTask>
<endEvent id="endevent1" name="End"></endEvent>
<sequenceFlow id="flow1" sourceRef="startevent1" targetRef="servicetask1"></sequenceFlow>
<sequenceFlow id="flow2" sourceRef="servicetask1" targetRef="usertask1"></sequenceFlow>
<sequenceFlow id="flow3" sourceRef="usertask1" targetRef="endevent1">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${action=="complete"}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="flow4" name="Retry" sourceRef="usertask1" targetRef="servicetask1">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${action=="retry"}]]></conditionExpression>
</sequenceFlow>
</process>
</definitions>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
<property name="jdbcUrl" value="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000" />
<property name="jdbcDriver" value="org.h2.Driver" />
<property name="jdbcUsername" value="sa" />
<property name="jdbcPassword" value="" />
<!– I've tried multiple combinations of these… –>
<!–<property name="jobExecutorActivate" value="false" />–>
<!–<property name="jobExecutorEnabled" value="false" />–>
<!–<property name="asyncExecutorEnabled" value="false" />–>
<!–<property name="asyncExecutorActivate" value="false" />–>
<property name="databaseSchemaUpdate" value="true" />
</bean>
</beans>
public class NothingServiceTask implements JavaDelegate {
@Override
public void execute(DelegateExecution execution) throws Exception {
System.out.println("I do nothing");
}
}
01-21-2015 09:25 AM
01-21-2015 11:33 AM
01-23-2015 08:25 AM
01-23-2015 09:19 AM
02-09-2015 05:53 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.