Saimuga
Saimuga

Reputation: 435

Spring Batch Stops exactly at 2 hours 10 minutes everytime

I have written a spring batch with Reader and Writer (No Processor). All it does is based upon the input records from the reader, loads the data from few source tables to archive tables. I am calling a stored procedure in the writer which loads the records to archive tables and deletes from the source tables. But I am running into a strange behavior, Every time I start the batch it performs the archiving process but stops abruptly at 2 hours 10 minutes of execution time. Even if i rerun, again runs for 2 hours and 10 minutes and stops the execution. But the archival is not fully completed. There are no errors in the log except the below line.

Error Log :

2022-08-29 17:12:09.157  INFO 9109612 --- [SpringApplicationShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2022-08-29 17:12:09.158 TRACE 9109612 --- [SpringApplicationShutdownHook] o.h.type.spi.TypeConfiguration$Scope     : Handling #sessionFactoryClosed from [org.hibernate.internal.SessionFactoryImpl@c647c96f] for TypeConfiguration
2022-08-29 17:12:09.158 DEBUG 9109612 --- [SpringApplicationShutdownHook] o.h.type.spi.TypeConfiguration$Scope     : Un-scoping TypeConfiguration [org.hibernate.type.spi.TypeConfiguration$Scope@9239dddd] from SessionFactory [org.hibernate.internal.SessionFactoryImpl@c647c96f]

Below is my batch Writer implementation. Can someone please shed some light on this ?

@Override
public void write(List<? extends Account> items) throws Exception {
    
    DataSource dataSource= (DataSource) ctx.getBean("dataSource");
    this.jdbcTemplate = new JdbcTemplate(dataSource);
    
    for (cvObj : items) {

        logger.info("Going to archive for batch ");
        jdbcTemplate.update(QUERY_INSERT_ARCHIVE,cvObj.getRunner);  
        jdbcTemplate.update("{ call pArchiveRecords (?) }", cvObj.getRunner);
        logger.info("Archival completed for ::: "+cvObj.getRunner);
        jdbcTemplate.update(QUERY_UPDATE_ARCHIVE,cvObj.getRunner);
        
        
    }
    

}

Upvotes: 0

Views: 322

Answers (0)

Related Questions