Created
January 7, 2011 19:34
-
-
Save nurkiewicz/769977 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<bean id="dataSource" class="org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy"> | |
<property name="targetDataSource"> | |
<bean class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> | |
<property name="driverClassName" value="org.h2.Driver" /> | |
<property name="url" value="jdbc:h2:~/workspace/h2/activiti;DB_CLOSE_ON_EXIT=FALSE;TRACE_LEVEL_FILE=4" /> | |
<property name="username" value="sa" /> | |
<property name="password" value="" /> | |
</bean> | |
</property> | |
</bean> | |
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> | |
<property name="dataSource" ref="dataSource" /> | |
</bean> | |
<!-- Workaround to http://jira.codehaus.org/browse/ACT-473 --> | |
<bean id="initProcessEngines" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> | |
<property name="staticMethod" value="org.activiti.engine.ProcessEngines.init"/> | |
</bean> | |
<bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean" depends-on="initProcessEngines"> | |
<property name="processEngineConfiguration"> | |
<bean class="org.activiti.spring.SpringProcessEngineConfiguration"> | |
<property name="databaseType" value="h2" /> | |
<property name="dataSource" ref="dataSource" /> | |
<property name="transactionManager" ref="transactionManager" /> | |
<property name="databaseSchemaUpdate" value="none" /> | |
<property name="jobExecutorActivate" value="false" /> | |
<property name="deploymentResources" value="classpath*:/com/blogspot/nurkiewicz/tryipad2/bpmn20/*.bpmn20.xml" /> | |
</bean> | |
</property> | |
</bean> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" /> | |
<bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" /> | |
<bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" /> | |
<bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" /> | |
<bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<process name="ForkJoin" id="ForkJoin" isExecutable="false"> | |
<startEvent id="Start" name="Start"/> | |
<userTask id="Task_0" name="Task 0"/> | |
<parallelGateway gatewayDirection="Diverging" id="Fork_AB" name="Fork AB"/> | |
<userTask id="Task_A" name="Task A"/> | |
<userTask id="Task_B" name="Task B"/> | |
<parallelGateway gatewayDirection="Diverging" id="Fork_B" name="Fork B"/> | |
<userTask id="Task_B1" name="Task B1"/> | |
<parallelGateway gatewayDirection="Converging" id="Join_B" name="Join B"/> | |
<userTask id="Task_B2" name="Task B2"/> | |
<parallelGateway gatewayDirection="Converging" id="Join_AB" name="Join AB"/> | |
<userTask id="Task_C" name="Task C"/> | |
<endEvent id="End" name="End"/> | |
<sequenceFlow id="Flow_2" name="" sourceRef="Fork_AB" targetRef="Task_A" /> | |
<sequenceFlow id="Flow_5" name="" sourceRef="Fork_AB" targetRef="Task_B" /> | |
<sequenceFlow id="Flow_7" name="" sourceRef="Task_B" targetRef="Fork_B" /> | |
<sequenceFlow id="Flow_0" name="" sourceRef="Fork_B" targetRef="Task_B1" /> | |
<sequenceFlow id="Flow_1" name="" sourceRef="Fork_B" targetRef="Task_B2" /> | |
<sequenceFlow id="Flow_11" name="" sourceRef="Task_B1" targetRef="Join_AB" /> | |
<sequenceFlow id="Flow_10" name="" sourceRef="Task_B2" targetRef="Join_AB" /> | |
<sequenceFlow id="Flow_4" name="" sourceRef="Task_A" targetRef="Join_AB" /> | |
<sequenceFlow id="Flow_8" name="" sourceRef="Join_AB" targetRef="Task_C" /> | |
<sequenceFlow id="Flow_12" name="" sourceRef="Task_C" targetRef="End" /> | |
<sequenceFlow id="Flow_9" name="" sourceRef="Start" targetRef="Task_0" /> | |
<sequenceFlow id="Flow_6" name="" sourceRef="Task_0" targetRef="Fork_AB" /> | |
</process> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static org.fest.assertions.Assertions.assertThat; | |
import org.activiti.engine.RuntimeService; | |
import org.activiti.engine.runtime.ProcessInstance; | |
@RunWith(SpringJUnit4ClassRunner.class) | |
@ContextConfiguration(locations = "classpath:/com/blogspot/nurkiewicz/tryipad2/activiti/ActivitiTestCase-context.xml") | |
public class ForkJoinTest { | |
@Resource | |
private RuntimeService runtimeService; | |
@Test | |
public void shouldRunConcurrently() throws Exception { | |
final ProcessInstance process = runtimeService.startProcessInstanceByKey("ForkJoin"); | |
final String pid = process.getId(); | |
//... | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
log.debug("Waiting in Task 0"); | |
assertThat(runtimeService.getActiveActivityIds(pid)).containsOnly("Task_0"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//only one execution | |
assertThat( | |
runtimeService | |
.createExecutionQuery() | |
.processInstanceId(pid) | |
.list() | |
).hasSize(1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
log.debug("Signaling advances to Task A and B concurrently"); | |
runtimeService.signal(pid); | |
assertThat(runtimeService.getActiveActivityIds(pid)).containsOnly("Task_A", "Task_B"); | |
//three execution | |
assertThat( | |
runtimeService | |
.createExecutionQuery() | |
.processInstanceId(pid) | |
.list() | |
).hasSize(3); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final Execution forkA = runtimeService | |
.createExecutionQuery() | |
.activityId("Task_A") | |
.processInstanceId(pid) | |
.singleResult(); | |
log.debug("Found forked execution {} in Task A activity for process {}", forkA, pid); | |
runtimeService.signal(forkA.getId()); | |
log.debug("Advanced fork A, waiting in Join AB"); | |
assertThat(runtimeService.getActiveActivityIds(pid)).containsOnly("Task_B"); | |
//no active activities in fork A since waiting in join | |
assertThat(runtimeService.getActiveActivityIds(forkA.getId())).isEmpty(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
svn co http://svn.codehaus.org/activiti/activiti/tags/activiti-5.1 | |
cd activiti-5.1 | |
mvn install source:jar -DskipTests -Pdistro |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Leaving activity 'Task_A' | |
ConcurrentExecution[12256734] takes transition (Task_A)--Flow_4-->(Join_AB) | |
ConcurrentExecution[12256734] executes Activity(Join_AB): org.activiti.engine.impl.bpmn.ParallelGatewayActivity | |
parallel gateway 'Join_AB' does not activate: 1 of 3 joined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment