Summary of Building batch framework issues Spring Batch + Spring batch Admin + Quartz

Source: Internet
Author: User
Tags commit rollback

Transaction Manager Transaction manager issue:

problem Phenomenon: call the DAO Update update data in Tasklet to discover that the database has not changed.

problem Analysis: guess is no commit

Originally, I used the spring batch admin as the batch interface management,

But Spring-batch-admin-manager*.jar internal Data-source-context.xml defines the data source and transaction manager

With the DataSource of my DAO module, transaction manager conflicts.


Two transaction managers are actually used here:

* 1) TransactionManager frame-related tables used for spring batch registration Batch_ start:
* Configured in the data-source-context.xml of Spring-batch-manager.jar.
* Jobrepository, Jobregistry, Joblauncher, Jobservice are all using this transaction manager.
*
* 2) to control the submission and rollback of business logic data in Taskletstep (Invoke DAO),
* So you must be the same object as the MyBatis transaction manager Txmanager in Act-dao to have spring batch automatically commit and rollback in transactiontemplate
* If the transaction manager used by spring batch and DAO is not the same, it will cause the DAO update to be lost.


The original code is automatically injected with the problem, using the above 1) TransactionManager:

@Resource
Platformtransactionmanager TransactionManager;

Taskletstep.settransactionmanager (TransactionManager);


Solution: Taskletstep instead of DAO, use 2) Txmanager

@Resource (name= "Txmanager")
Platformtransactionmanager Txmanager;

Taskletstep.settransactionmanager (Txmanager);


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.