简体   繁体   中英

Spring Batch metadata database transaction problem

I am using Spring Batch (version 4.1.2). The problem is the following:

1/ batch job is step oriented (2 steps), the first step loads data from oracle database (customer orders - the only small amount of data), filters them for further processing and stores the result into an in-memory object (orderNo - ie process this order in the second step)

2/ second step takes these filtered data from memory and processes them - loads data (now full amount of data, full order) and process them - starts stored procedure in oracle and then calls some external web service

The first step is very fast - approx. 5 sec.

The second step is very slow - for every customer order, it takes approx. 10 sec.

Typical size of data: the First step loads thousands of orders and filters approx. 100-300 orders for further processing in the second step.

Configuration for the first step: a chunk of 100 orders

Configuration for second step: chunk = 1

And the problem: If the second step (calling web service) failes, the metadata database transaction fails because of timeout. Or if the job completes OK, again the metadata database fails with timeout. Why? The transaction timeout is set to 30 seconds. It looks to me that the transaction of the metadata database is not affected by the chunk configuration.

Note: order database: oracle, metadata database: postgresql

Any suggestions, solutions, etc, please?

@Transactional(propagation = Propagation.REQUIRES_NEW)

on ItemProcessor method

O process(I var1) throws Exception;

was solution of the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM