Tasklet事务管理器和区块事务



我指定了一个具有面向块的进程的tasklet。

<batch:step id="midxStep" parent="stepParent">
<batch:tasklet transaction-manager="transactionManager">
<batch:chunk
reader="processDbItemReaderJdbc"
processor="midxItemProcessor"
writer="midxCompositeItemWriter"
processor-transactional="false"
reader-transactional-queue="false"
skip-limit="${cmab.batch.skip.limit}"
commit-interval="#{jobParameters['toProcess']==T(de.axa.batch.ecmcm.cmab.util.CmabConstants).TYPE_POSTAUSGANG ? '${consumer.global.pa.midx.commitSize}' : '${consumer.global.pe.midx.commitSize}' }"
cache-capacity="20">
<batch:skippable-exception-classes>
<batch:include class="de.axa.batch.ecmcm.cmab.util.CmabProcessMidxException" />
<batch:exclude class="java.lang.IllegalArgumentException" />
</batch:skippable-exception-classes>
<batch:retryable-exception-classes>
<batch:include class="de.axa.batch.ecmcm.cmab.util.CmabTechnicalMidxException" />
<batch:include class="de.axa.batch.ecmcm.cmab.util.CmabTechnicalException" />
</batch:retryable-exception-classes>
<batch:retry-listeners>
<batch:listener ref="logRetryListener"/>
</batch:retry-listeners>
<batch:listeners>
<batch:listener>
<bean id="midxProcessSkipListener" class="de.axa.batch.ecmcm.cmab.core.batch.listener.CmabDbSkipListener" scope="step">
<constructor-arg index="0" value="#{jobParameters['errorStatus']}" type="java.lang.String"/>
</bean>
</batch:listener>
</batch:listeners>
</batch:chunk>
<batch:transaction-attributes isolation="SERIALIZABLE" propagation="MANDATORY" timeout="${cmab.jta.usertransaction.timeout}"/>
<batch:listeners>
<batch:listener ref="midxStepListener"/>
<batch:listener>
<bean id="cmabChunkListener" class="de.axa.batch.ecmcm.cmab.core.batch.listener.CmabChunkListener" scope="step"/>
</batch:listener>
</batch:listeners>
</batch:tasklet>
</batch:step>

小任务使用JtaTransaction管理器(Atomikos,name="transactionManager"(运行
现在我的问题是:
这个交易经理"委托";到chunk过程
我为什么要问这个?如果我将事务属性(参见块(设置为传播级别"0";强制的";块进程中止,错误为没有可用的事务。因此,这让我感到困惑,因为我认为tasklet事务规范也暗示了在这个tasklet事务中运行的块。

此外,我打算在具有多个pod的云系统中运行该应用程序
processDbIemReaderJdbs通过StoredProcedureItemReader获取带有";FOR UPDATE SKIP LOCKED";来自PostgresDB
因此,我的意图是运行漏洞区块,也就是在一个事务内的读取器,以便将读取器resultSet阻止到其他POD进程。

事务属性用于Spring Batch将创建的事务,以便使用您在步骤上设置的事务管理器来运行您的步骤。这些是事务本身的属性,而不是事务管理器(这没有意义(。

所有批处理工件都在同一事务的范围内执行,包括读取器和写入器。唯一的例外是JdbcCursorItemReader,默认情况下它不参与事务,除非设置了useSharedExtendedConnection

最新更新