spring-batch

Accessing name of flat file from FlatFileItemReader LineMapper

泄露秘密 提交于 2019-12-11 06:08:12
问题 I have a need to be able to access the name of the flat file that the current line being read is from. We are porting an application and some processes that are currently in place require this information. Here is my current configuration: private FlatFileItemReader<Invoice> invoiceFlatFileItemReader() throws Exception { FlatFileItemReader<Invoice> reader = new FlatFileItemReader<>(); reader.setLinesToSkip(1); // header row reader.setLineMapper(new InvoiceLineMapper()); reader

Database session still open after spring batch processing

无人久伴 提交于 2019-12-11 06:02:35
问题 I'm currently developing an application that processes a large file file and stores it in a JPA database with spring batch. This happens on request. And after a batch is done you can use the same service to get information about the data loaded in the database on request. Separately these requests work, but if I try combining them I get an error in my unit tests when persist and flushing entities in the database via the TestEntityManger. The error is: javax.persistence

dropping of meta data tables by spring batch

混江龙づ霸主 提交于 2019-12-11 05:55:41
问题 In Spring Batch , when are meta data tables dropped? I see drop sql file at - /org/springframework/batch/core/... but not sure if its some trigger from program ( Batch Job itself ) that drops these tables or these tables need to be dropped manually or does it have anything to do with batch admin? 回答1: I suppose they are never dropped automatically but a manual action is always required (from SB admin) or from your application (as part of your application service layer) 回答2: The meta data

Spring Integration - outbound transfer renaming issues

☆樱花仙子☆ 提交于 2019-12-11 05:55:30
问题 I am using the sample program here to build my code. Everything works fine with the local SFTP test server, When I tested today in my client SFTP servers, it gave me an exception as below. When I debugged I saw the file being written with '.writing' extension on the client's SFTP server. The contents are fine, I don't see any issues with the file that was transferred but the file name is the issue now. After reading through the spring docs, I see that this is the temporary file extension, and

Passing variables to process

六眼飞鱼酱① 提交于 2019-12-11 05:55:15
问题 In Spring Batch I have a custom ItemProcessor. I want to pass information from the afterStep to the process method. Here's the code @Component public class Clf010Processor implements ItemProcessor<Clf010Item, Clf010Item> { private StepExecution stepExecution; BatchProgram batch = new BatchProgram(); @AfterStep public void afterStep(StepExecution stepExecution) { ExecutionContext je = stepExecution.getJobExecution().getExecutionContext(); // Pass the counts up to the execution context. je

Spring Batch and rollback not occured after exception in ItemWriter

喜夏-厌秋 提交于 2019-12-11 05:39:52
问题 I have Spring batch job with chunk and setting commit-interval="3" and declared skipable exceptions. I want to save 3 item in DB: item_1 item_2 item_3 Say, I want to save this items in database but second item is invalid and an exception is occured. In this situation should couse rollback and Spring Batch should rerun each item of the problematic chunk individually with one commit/transaction for each item. So in database should be saved item_1 and item_3. But in my case in database is saved:

Spring Batch: Job Properties

半世苍凉 提交于 2019-12-11 05:36:20
问题 How can i add property: <property name="myProperty" value="value"/> To the batch job definition: <batch:job id="MyJob"> <batch:description>description</batch:description> <batch:step id="step0"> <batch:tasklet ref="MyJobCls"/> <batch:listeners> <batch:listener ref="MyJobkListener"/> </batch:listeners> </batch:step> </batch:job> then i can use this property in my run time. 回答1: You can have the properties in an external file or inject it in PropertyPlaceholderConfigurer from xml: <bean id=

Does jobRepository have to use the same transaction manager as the JdbcBatchItemWriter?

孤人 提交于 2019-12-11 05:04:36
问题 I am developing a Spring Batch enterprise application. The objective of the application is to write records to a table in a legacy database from the company I work for. That database is really big boy that stores business and customer information in huge number of schemas and tables with hundreds of millions of records, there are also hundreds of applications that connect to it: ERPs, CRMS, internal applications, .com. Because of that, I cannot create the job metadata tables needed by the

org.springframework.dao.DataAccessResourceFailureException: Unable to write to file resource: [class path resource [report.xml]]; Spring Batch

放肆的年华 提交于 2019-12-11 04:58:11
问题 I am developing Spring Batch - MongoDB to XML example. I have successfully developed the code, when I run the my main program. I see the following eror comes. I am not sure what is going wrong. I followed many links, but I dont see its not working fine. org.springframework.dao.DataAccessResourceFailureException: Unable to write to file resource: [class path resource [report.xml]]; nested exception is java.io.FileNotFoundException: class path resource [report.xml] cannot be resolved to URL

Spring Batch JpaPagingItemReader read only first results

牧云@^-^@ 提交于 2019-12-11 04:38:07
问题 I am using the JpaPagingItemReader in a Batch that modifies the data underlying the Readers query. The writer sets a Status to COMPLETED and then moves on processing the next chunk. The outcome is that rows are omitted. When you have 100 rows to process and a chunk (and Reader size) of 10, the Reader reads 10 rows and processes them. With the second read he then tries to read Page 2 of the data but in my case uses a query that also questions the Status in it's where-clause. So the amount of