spring-batch

Spring Batch - JdbcCursorItemReader throwing OutOfMemoryError with large MySQL table

末鹿安然 提交于 2019-12-04 19:25:42
I am writing a program using Spring Batch to process 7,637,064 rows from a MySQL database table. I've had success with smaller tables, but the large number of rows in this table is causing OutOfMemoryError exceptions when the JdbcCursorItemReader attempts to open the cursor. I could probably resolve this by throwing a larger Xmx at it, but it seems to me that Spring Batch should have a way to handle this and that I may simply be missing a key piece of configuration. Spring Batch configuration: <job id="reportJob" xmlns="http://www.springframework.org/schema/batch"> <step id="largeTableTransfer

Spring Batch - how to fail a job when the ItemReader returns no data

∥☆過路亽.° 提交于 2019-12-04 19:03:32
I have a spring batch application which reads data from a DB table with JdbcCursorItemReader and writes it to a flat file with FlatFileItemWriter. When I test my application, I see that the FlatFileItemWriter creates a file even if no data is returned from the DB via JdbcCursorItemReader. However, I'm planning to fail my job when there is no appropriate data in DB. Is it possible to do so or at least prevenet FlatFileItemWriter from creating a file? Regards from http://static.springsource.org/spring-batch/reference/html/patterns.html 11.7. Handling Step Completion When No Input is Found In

java.lang.NoSuchMethodError: org.hibernate.SessionFactory.getCurrentSession()Lorg/hibernate/Session;

纵饮孤独 提交于 2019-12-04 18:47:12
I'm trying to integrate a batch with my application i'm using hibernate-core-3.6.3 and hibernate-hibernate-commons-annotations-3.2.0 and spring-batch-core-3.0.1 And when I try to insert into the database when I run the batch this error appears. Here is my spring-batch-context <beans xmlns="http://www.springframework.org/schema/beans" xmlns:batch="http://www.springframework.org/schema/batch" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-3.0.xsd http://www

Calling another job from a processor in spring batch

谁都会走 提交于 2019-12-04 17:53:32
I have a job(= JobA ) that reads and processes an input file - this Job is defined using a reader, writer, several processors, listeners and exception handlers and i don't want to change this job definition mainly for backwards compatibility reasons I want to implement another job(= JobB ) that reads files from a directory with a certain criteria and in a certain order and then sends the files to be processed by JobA I was looking into [MultiResourceItemReader][1] [1]: http://docs.spring.io/spring-batch/apidocs/org/springframework/batch/item/file/MultiResourceItemReader.html

@StepScope within Spring batch throw exception when trying pass param

有些话、适合烂在心里 提交于 2019-12-04 17:13:19
I am having hard time to combine Spring-batch with Spring-batch-admin using Spring-boot. Because I am using Spring-batch-admin I had to disable @EnableBatchProcessing and I manually configured the two builders it provides. that came from my question here: Error Integrating spring-batch and Spring-Batch-admin Now I am trying to do simple scenario when I want to pass param from jobContext params into ItemReader using @StepScope and injection of the properties I followed the example over here(the example is without spring-batch-admin and spring boot) using @StepScope explanation And I get this

Can we use @Autowired in a Tasklet in Spring Batch?

痴心易碎 提交于 2019-12-04 16:43:32
I have a Spring Batch tasklet as follows in my application. @Service public class SampleTasklet implements Tasklet { @Autowired private UserService userService; @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { System.err.println(userService.getUsers().size()); return RepeatStatus.FINISHED; } } and I have a Service Class as follows. @Service @Slf4j public class UserService { public Map<String, String> getUsers(){ return null } } Spring Boot class : @SpringBootApplication @Slf4j public class SampleBatchApp { public static void

Spring Batch Stax XML reading job is not ending when out of input

…衆ロ難τιáo~ 提交于 2019-12-04 16:42:38
I'm using Spring Batch to set up a job that will process a potentially very large XML file. I think I've set it up appropriately, but at runtime I'm finding that the job runs, processes its input, and then just hangs in an executing state (I can confirm by viewing the JobExecution's status in the JobRepository). I've read through the Batch documentation several times but I don't see any obvious "make the job stop when out of input" configuration that I'm missing. Here's the relevant portion of my application context: <batch:job id="processPartnerUploads" restartable="true"> <batch:step id=

Spring Batch Paging with sortKeys and parameter values

寵の児 提交于 2019-12-04 16:41:24
I have a Spring Batch project running in Spring Boot that is working perfectly fine. For my reader I'm using JdbcPagingItemReader with a MySqlPagingQueryProvider. @Bean public ItemReader<Person> reader(DataSource dataSource) { MySqlPagingQueryProvider provider = new MySqlPagingQueryProvider() provider.setSelectClause(ScoringConstants.SCORING_SELECT_STATEMENT) provider.setFromClause(ScoringConstants.SCORING_FROM_CLAUSE) provider.setSortKeys("p.id": Order.ASCENDING) JdbcPagingItemReader<Person> reader = new JdbcPagingItemReader<Person>() reader.setRowMapper(new PersonRowMapper()) reader

Reading Records From a Database in Spring Batch

*爱你&永不变心* 提交于 2019-12-04 15:50:27
I'm trying to read some records from a database using loops then do some calculations on the records (updating a field called total). But i'm new to spring batch so please can anyone provide me with some tips. incomplete-co.de this sounds like something the chunk pattern would address. you can use re-use existing Spring Batch components to read from the database, compose your own processor, then pass back to a Spring Batch component to store. say the use case is like this; - read a record - record.setTotalColumn(record.getColumn2() + record.getColumn3()) - update this configuration might look

No Exception when Spring batch tables are not created

自古美人都是妖i 提交于 2019-12-04 15:48:30
问题 If the BATCH_JOB_EXECUTION_CONTEXT was not created all I get is : Caused by: org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [INSERT INTO BATCH_JOB_EXECUTION_CONTEXT (SHORT_CONTEXT, SERIALIZED_CONTEXT, JOB_EXECUTION_ID) VALUES(?, ?, ?)]; nested exception is java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist the error above is displayed while inserting into the table, but at the moment of the creation of the table (done