AnsweredAssumed Answered

Independently commiting transactions

Question asked by gul on Feb 25, 2016
Latest reply on Feb 25, 2016 by martin.grofcik
I have an all-service-task(ST) workflow with a waitTask to force activiti to perists data( and to avoid stack overflows).    

ST1 –> ST2 –> ST3 –> ST4 –> WaitTask –> Exclusive Gateway –> (if TRUE –> End,
                                              else –> Point back to ST2)
Each of my service tasks are complex; as they persists several hundred records into database.
The problem is, the data is not committed until the process hits waitTask.  Though I am not sharing the same transaction manager.  
How can I make the transactions created by Activiti and by my service task commit independent.

<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
      <property name="dataSource" ref="dataSource" />
      <property name="transactionManager" ref="transactionManagerActiviti" />
      <property name="databaseSchemaUpdate" value="false" />
      <property name="jobExecutorActivate" value="false" />
      <property name="asyncExecutorEnabled" value="true" />
      <property name="asyncExecutorActivate" value="true" />
      <!–  Need to Validate this –>
      <property name="deploymentResources" value="classpath*:processes/activiti/*bpmn20.xml" />
<bean id="transactionManagerActiviti"   class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
      <property name="dataSource" ref="datasourceForOracle"/>      
      <property name="globalRollbackOnParticipationFailure" value="false"></property>
<!– Transaction Manager used by service tasks–>

<bean id="transactionManager"
      <property name="dataSource" ref="datasourceForOracle">
         <ref bean="$cashavailDataSource{cashavail.dataSourceBeanName}" />


ProcessInstance pi = runtimeService.startProcessInstanceByKey("customProcess",processContextMap);
Execution execution = null;
while ((execution = runtimeService.createExecutionQuery().processInstanceId(pi.getId()).activityId("waitStateReceiveTask")
            .singleResult()) != null) {