spring-batch

Spring Batch, JdbcExecutionContextDao java.util.Map$Entry deserializer issue, xstream 1.4.1

旧城冷巷雨未停 提交于 2019-12-03 15:21:28
I have a problem using Spring Batch 2.1.9: when i use jobExplorer.getJobExecution(jobExecutionId) , i find a problem when DAO has to deserialize a string like: {"map":[{"entry":{"string":"parsedComparingDate","date":"2014-03-08 23:00:00.0 UTC"}}]} from the BATCH_JOB_EXECUTION_CONTEXT table, using method JdbcJobExecutionDao.getJobExecution() . I know that spring batch uses xstream 1.3, but in my Pom, i have: spring-batch 2.1.9 ; xstream 1.4.1 (inherited from smooks); jettison 1.3.3 (inherited from cxf); Also, i read that xstream 1.3 does not work fine with jettison 1.3.3, but using xstream 1.3

How to get JobParameter and JobExecutionContext in the ItemWriter?

会有一股神秘感。 提交于 2019-12-03 15:20:17
问题 I want to retrieve JobParameter and JobExecutionContext object in my ItemWriter class. How to proceed? I tried implementing StepExecutionListener through which I am just calling the parent class methods. But it is not succeeding. Thanks in advance. 回答1: Implementing StepExecutionListener is one way. In fact that's the only way in Spring Batch 1.x. Starting from Spring Batch 2, you have another choice: You can inject whatever entries in Job Parameters and Job Execution Context to your item

What is the function of JobBuilderFactory.get(job).incrementer(RunIdIncrementer)?

試著忘記壹切 提交于 2019-12-03 14:48:39
I'm developing a Spring-Batch project using Spring-Boot and everything is going along nicely. I've done a few spring-batch examples (including some from spring.io), but I'm not sure what some of the stuff does, and "it just works" doesn't satiate me. My spring boot main class implements CommandLineRunner and for this particular job the initial set up looked like @Bean public Job myJob(JobExecutionListenerSupport listener) { return myJobBuilderFactory.get(JOB) .listener(listener) .start(myStep()) .build(); } Which caused java.lang.IllegalStateException: Failed to execute CommandLineRunner at

Batch Insertions with Hibernate & Spring

纵饮孤独 提交于 2019-12-03 13:44:48
问题 My application is based on Hibernate 3.2 and Spring 2.5. Here is the transaction management related snippet from the application context: <tx:annotation-driven transaction-manager="txManager"/> <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"/> <property name="nestedTransactionAllowed" value="true"/> </bean> <bean id="transactionTemplate" classs="org.springframework.transaction.support

Deciding between Spring Batch Step, Tasklet or Chunks

为君一笑 提交于 2019-12-03 11:50:59
问题 I have a straight forward requirement in which, i need to read a list of items(from DB) and need to process the items and once processed, it has to be updated into DB. I'm thinking of using Spring batch Chunks with reader, processor and writer. My reader will return one item at a time from the list and sends it to processor and once processing is over, it returns to Writer where it updates the DB I may be multithreading it later with some cost of synchronization in these methods. Here I

Add parameter to job context from tasklet step and use in later steps in Spring Batch

梦想与她 提交于 2019-12-03 10:50:00
For now, I'm using jobParameters to get the filenames for both my FlatFileItemReader and FlatFileItemWriter. It's okay for testing my batch, but my goal is to read a file in some directory (there is only this file in this directory) and the filename might change. The output filename should depend on the input filename. Therefore, I thought about adding a new step to my job, and this step will set both output and input filenames by searching the good directory and looking for the file into it. I read Passing Data to Future Steps from Spring Doc, and this thread from SO, but I can't make it work

No Exception when Spring batch tables are not created

不想你离开。 提交于 2019-12-03 09:09:02
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 automatically by spring batch )no error was displayed. I would like to know the reason way the table was not

Run Spring Batch Job programmatically?

不羁岁月 提交于 2019-12-03 09:00:31
问题 I have a Spring Batch application, which I start with the CommandLineJobRunner . But now I have to embed this application into our corporate environment. There we have an own Launcher application which I have to use. For this launcher application I need a startup class with a main method which will be called at startup and where I would have to launch Spring Batch. Is the only way to manually assign a JobLauncher and run the Job with this launcher or is there a class in Spring Batch which

Spring RESTful web services - High volume data processing

瘦欲@ 提交于 2019-12-03 08:57:30
I'm trying to build a Spring/Spring Boot- RESTful web service, Which accepts a CSV file with 1 million rows/40 columns in each row as input (From a Angular based front end) and will be a synchronous call. User have to be notified on the upload status before proceeding to other screens. So, wait time can't be more than few mins(say 5 mins). Each of these rows has to be validated against what is in DB and if found to be valid, same will be inserted into DB. In short, each row can be a separate independent transaction. Can you please suggest what would be the best approach to implement this?

Spring Batch: One reader, multiple processors and writers

无人久伴 提交于 2019-12-03 08:42:28
问题 In Spring batch I need to pass the items read by an ItemReader to two different processors and writer. What I'm trying to achieve is that... +---> ItemProcessor#1 ---> ItemWriter#1 | ItemReader ---> item ---+ | +---> ItemProcessor#2 ---> ItemWriter#2 This is needed because items written by ItemWriter#1 should be processed in a completely different way compared to the ones written by ItemWriter#2. Moreover, ItemReader reads item from a database, and the queries it executes are so computational