在我的 Spring Batch 作业中禁用事务 [英] Disable transactions in my Spring Batch job

查看:162
本文介绍了在我的 Spring Batch 作业中禁用事务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的数据库中插入一条记录,以便另一个系统可以读取该记录.之后,我将(使用我的 ItemWriter)将我从该系统收到的响应写入 CSV 文件.

I need to insert a record in my database so another system can read that record. After that, I will write (with my ItemWriter) the response I recieve from that system in a CSV file.

我的问题是系统无法读取记录,因为 Spring Batch 是事务性的.如何禁用该属性?

My problem is that the system can't read the record since Spring Batch is transactional. How can I disable that property?

推荐答案

您不想禁用事务强制,因为这可能会导致严重的数据完整性问题.即使是 1% 的错误问题也很容易造成数以万计,甚至数以千万计的不完整或不良记录.特别是如果说您正在与之交互的数据库之一或您正在写入的文件系统变得不可用.随着时间的推移,这将会发生.它还会破坏作业重试功能.

You do not want to disable transaction enforcement, that can open you up to a serious data integrity problem. Even a 1% error issue can easily cause cause ten's of thousands, or even tens of millions of incomplete or bad records. Especially if say the one of the databases you are interacting with, or file systems you are writing to become unavailable. Which over time WILL happen. It would also break the job retry features.

更好的选择是将流程分解为多个步骤或作业,以便事务边界适合您的流程.因此,其中一个写入到另一个数据库中,然后下一步或作业会读取和写入文件.

A better option would be to break the process up into multiple steps, or jobs so the transaction boundaries fit your process. So one of them write out to this other database, and then the next step or job does the reading and writing to the file.

这篇关于在我的 Spring Batch 作业中禁用事务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆