首页 > 解决方案 > 春季批处理分布式事务配置 IBM Liberty

问题描述

我必须配置 Spring Batch 才能在 IBM Liberty AS 中工作。主要问题是事务的配置。我的一些配置。

在 Liberty server.xml 文件中:

<dataSource id="ectxDS"
            jndiName="jdbc/ectxDS"
            isolationLevel="TRANSACTION_SERIALIZABLE"
            transactional="true">
        <jdbcDriver libraryRef="OracleLib"/>
        <properties.oracle URL="jdbc:oracle:thin:..."
            password="..."
            user="..."/>
    </dataSource>

在 Spring context.xml 中:

<!-- *** DATASOURCE *** -->
<jee:jndi-lookup id="dataSource"
    jndi-name="jdbc/ectxDS"
    expected-type="javax.sql.DataSource" />

<!-- *** JDBC TEMPLATE *** -->
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
    <constructor-arg name="dataSource" ref="dataSource" />
</bean>

<!-- *** TX MANAGER *** -->
<bean id="transactionManager" class="org.springframework.transaction.jta.WebSphereUowTransactionManager">
</bean>

使用此配置,在调用 JdbcTemplate 类的方法(更新、查询...)时会发生提交:我需要 Spring Batch 根据其默认值管理事务,例如Tasklet执行方法必须是事务性的!同时,我需要利用类org.springframework.transaction.jta.WebSphereUowTransactionManager使用分布式事务。

也许我错过了一些东西:我使用 Spring Batch 的时间很短。

先感谢您。

标签: springspring-batchwebsphere-liberty

解决方案


推荐阅读