Hi
I am using Activiti with Spring integration. I have configured Activiti and Spring to use transaction manager as given below:
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="YYYY"/>
</bean>
<bean id="appsDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="XXXX"/>
</bean>
<bean id="workflowDbDAO" class="xy.init">
<property name="dataSource" ref="appsDataSource" />
</bean>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager"/>
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
<property name="dataSourceJndiName" value="YYYY" />
<property name="transactionManager" ref="transactionManager" />
<property name="databaseType" value="oracle" />
<property name="databaseSchemaUpdate" value="true" />
<property name="history" value="audit" />
<property name="jobExecutorActivate" value="true"/>
<property name="mailServerUseTLS" value="true" />
</bean>
<bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean" destroy-method="destroy">
<property name="processEngineConfiguration" ref="processEngineConfiguration" />
</bean>
<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" />
<bean id="identityService" factory-bean="processEngine" factory-method="getIdentityService" />
</beans>
I have a simple workflow as follows:
Start—>Service Task–>Mail Task—> User Task—>End
I have execution Listeners in all of the components. The execution Listeners performs insert/update to a external tables apart from Activiti Schema.
I have an exception thrown @Execution Listener in Service Task. I see that the transaction is handled in the following way:
1. Data in the Activiti Tables has been rolled back. This is as expected as a wait state was not reached. Hence the transaction roll backed.
2. The data changes to external tables have been committed instead of rollback.
I have questions for 2. Shouldn't the external DB and Activiti use the same transaction? If activiti transaction is getting rollbacked, why is the data in the external tables committed, even when an exception is thrown.
Any pointers on this issue will really help me. I am stuck at this point.