Atomikos Forum

SPRING BATCH - JPA - PARALEL PROCESS - NOT COMMIT

I found a big problem that I'm cannot resolve.

My tests is using the Spring Batch,JPA and ATOMIKOS, and works fine.
But when a I change the configuration of execution flow cycle of job, to use parallel configuration, my transaction is not commiting.

The configuration change is a declaration of taskExecutor on a tag split process.

In other words, when a job process in a single thread,transaction comming. But when a job process in a multi-thread, transaction not comming.

Example:

Template of EntityManager Configuration

    <bean id="abstractEntityManagerFactory"
          class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
          abstract="true">
        <property name="jpaVendorAdapter">
            <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                <property name="databasePlatform" value="org.hibernate.dialect.Oracle10gDialect" />
                <property name="showSql" value="true" />
            </bean>
        </property>
        <property name="jpaProperties">
            <props merge="true">
                <prop key="hibernate.bytecode.use_reflection_optimizer">false</prop>
                <prop key="hibernate.format_sql">false</prop>
                <prop key="hibernate.current_session_context_class">jta</prop>
                <prop key="javax.persistence.transactionType">jta</prop>
                <prop key="hibernate.transaction.factory_class">org.hibernate.ejb.transaction.JoinableCMTTransactionFactory</prop>
                <prop key="hibernate.transaction.manager_lookup_class">com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup</prop>
            </props>
        </property>
    </bean>

WORKS !!!
    
    <batch:job id="basico" parent="genericJob">
        <batch:listeners>
            <batch:listener ref="batchListener" />
        </batch:listeners>
        <batch:step id="basico.stepAParaB" next="basico.stepBParaA">
            <batch:tasklet transaction-manager="fakeTransactionManager">
                <batch:chunk reader="batchReaderA"
                             processor="batchProcessorAB"
                             writer="batchWriterB"
                             commit-interval="1" />
            </batch:tasklet>
        </batch:step>
        <batch:step id="basico.stepBParaA">
            <batch:tasklet transaction-manager="fakeTransactionManager">
                <batch:chunk reader="batchReaderB"
                             processor="batchProcessorBA"
                             writer="batchWriterA"
                             commit-interval="1" />
            </batch:tasklet>
        </batch:step>
    </batch:job>

    <bean id="entityManagerFactoryA"
          parent="abstractEntityManagerFactory">
        <property name="persistenceUnitManager" ref="persistenceUnitManagerA" />
    </bean>

    <bean id="entityManagerFactoryB"
          parent="abstractEntityManagerFactory">
        <property name="persistenceUnitManager" ref="persistenceUnitManagerB" />
    </bean>
    
NOT WORKS !!!!
    
    <batch:job id="avancado" parent="genericJob">
        <batch:listeners>
            <batch:listener ref="batchListener" />
        </batch:listeners>
        <batch:split id="avancado.split" task-executor="asyncTaskExecutor">
            <batch:flow>
                <batch:step id="avancado.stepAParaB">
                    <batch:tasklet transaction-manager="fakeTransactionManager">
                        <batch:chunk reader="batchReaderA"
                                     processor="batchProcessorAB"
                                     writer="batchWriterB"
                                     commit-interval="1" />
                    </batch:tasklet>
                </batch:step>
            </batch:flow>
            <batch:flow>
                <batch:step id="avancado.stepBParaA">
                    <batch:tasklet transaction-manager="fakeTransactionManager">
                        <batch:chunk reader="batchReaderB"
                                     processor="batchProcessorBA"
                                     writer="batchWriterA"
                                     commit-interval="1" />
                    </batch:tasklet>
                </batch:step>
            </batch:flow>
        </batch:split>
    </batch:job>

How can I explain better ?????

I post my at a web repository:
Valdir Antonio Correa Leite Scarin Send private email
Wednesday, May 09, 2012
 
 
I'm still woking on it ... AND ... I saw some thing really interesting ....

Inside of class BaseTransactionManager (extended by TransactionManagerImp) and used by UserTransactionManager.

When the method UserTransactionManager.getTransaction is called, the instance of TransactionManager (class TransactionManagerImpl) check if has some transaction opened for current """"THREAD"""" (method BaseTransactionManager .getCompositeTransaction and BaseTransactionManager.getCurrentTx)

Now ... Why I do ?

Has some type of TransactionManager that be used on multi-thread
Valdir Antonio Correa Leite Scarin Send private email
Thursday, May 10, 2012
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics