spring-batch

Issue with configuring Atomikos on a Spring Boot / Spring Batch application

丶灬走出姿态 提交于 2019-12-02 01:56:39
问题 I am trying to get Atomikos to work with my Spring Boot/Spring Batch application. Here is are the relevant portions of my code: Datasource config: @Configuration public class DatasourceConfiguration extends AbstractCloudConfig { @Bean @Qualifier("batch_database") public DataSource batchDatasource() { return connectionFactory().dataSource("batch_database"); } @Bean public PlatformTransactionManager transactionManager(){ return new JtaTransactionManager(); } @Bean public TaskConfigurer

Build non trivial XML file with StaxEventItemWriter

柔情痞子 提交于 2019-12-02 01:56:33
问题 I need to dump content of some database tables to XML file with this structure <dump> <table name="tableName1"> <records> <record> <first column name>value</first column name> <second column name>value</second column name> <third column name>value</third column name> </record> <record>...</record> </records> </table> <table name="tableName2">...</table> </dump> The real number of records for every table in unknown, so I can't store all data for a single table in memory and dump to XML. My job

Complex XML using Spring Batch; StaxEventItemWriter ; Jaxb2Marshaller

拈花ヽ惹草 提交于 2019-12-02 01:29:38
I need to write a slightly complex XML using Spring Batch. Can anyone please help me with the appropriate Spring configuration? Below is the Output the process requires. <XML> <USERLIST ID="something" NAME="Sample"> <USER ID="userID" NAME="Name"/> <USER ID="userID" NAME="Name"/> ........ </USERLIST> <XML> The 'UserList' in the XML above only needs to occur once This is the spring configuration I have so far. <bean id="userXMLWriter" class="org.springframework.batch.item.xml.StaxEventItemWriter"> <property name="resource" value="file:outputs/users.xml" /> <property name="encoding" value="ISO

Spring batch with column alias as sort key - malformed “where” statement

百般思念 提交于 2019-12-02 00:03:46
I'm using Spring-batch version 3.0.6.RELEASE to query a MySQL DB for some data and then process it. Details about usage: query provider is MySqlPagingQueryProvider when setting up the query provider I'm specifying an alias of one of the columns in the query as the sort key (please check the query below for more details) Query: SELECT target.tx_timestamp AS event_datetime, .... FROM some_table AS target .... WHERE target.tx_timestamp > :startTime AND target.tx_timestamp <= :endTime; The code: Map<String, Order> sortKeys = new HashMap<>(); sortKeys.put("event_datetime", Order.ASCENDING);

How to set max no of records read in flatfileItemReader?

荒凉一梦 提交于 2019-12-01 23:54:48
My application needs only fixed no of records to be read & processed. How to limit this if I am using a flatfileItemReader ? In DB based Item Reader, I am returning null/empty list when max_limit is reached. How to achieve the same if I am using a org.springframework.batch.item.file.FlatFileItemReader ? For the FlatFileItemReader as well as any other ItemReader that extends AbstractItemCountingItemStreamItemReader , there is a maxItemCount property. By configuring this property, the ItemReader will continue to read until either one of the following conditions has been met: The input has been

Seperate datasource for jobrepository and writer of Spring Batch

一世执手 提交于 2019-12-01 23:46:23
Job is simple CSVtoDBFileWriter : read CSV fileName and location from oracle1 read CSV file(batchreader) write(batch writer) in tables(oracle2) I have 2 datasource : Oracle1 : available when application context loads and : I read properties from Oracle1's tables to create oracle2 : jobRepository related tables should be stored here(oracle1) Oracle2 : Destination database where Spring batch's writer will finally output. Question1 : Do I need XA transactionManager? Question2 : Can I run this application in production only using Spring Boot, are there challanges with Spring Boot in production?

Spring Batch - more than one writer based on field value

主宰稳场 提交于 2019-12-01 23:00:23
I am working on spring batch, for writer currently using FlatFileItemWriter. I would like to write my input file content to more than one flat file based on some field value. Is Spring batch support any kind of functionality by default.[something similar to CompositeItemWriter] For example, my input file content is something like this. john,35,retail,10000 joe,34,homeloan,20000 Amy,23,retail,2000 Now i would like to write two different files based on third column, it means row 1 and row 3 should go to file1 and row 2 should go to file2. My writer configuration is: <bean id="fileWriter" class=

processing batch of records using spring batch before writing to DB

寵の児 提交于 2019-12-01 22:33:55
In the spring batch code, I am reading chunk of 100 records. for each record in the chunk I am checking whether the record exists in the DB or not. If the record exists in the DB I am not inserting it. For the first time, if I have a duplicate record in the chunk of 100, the spring batch processor is not able to identify that this record is duplicate as there is no data in DB and the processor will select all 100 first and then perform the insert. Is there a way I can perform a check within the chunk of 100 first and then check the DB and after these two I insert into the DB? You could

Spring batch Multithreaded processing for Single file to Multiple FIle

断了今生、忘了曾经 提交于 2019-12-01 22:29:54
My problem statement. Read a csv file with 10 million data and store it in db. with as minimal time as possible. I had implemented it using Simple multi threaded executor of java and the logic is almost similar to spring batch's chunk. Read preconfigured number of data from csv file and then create a thread, and passing the data to thread which validates data and then writes to file which runs in multi thread. once all the task is done I'm calling sql loader to load each file. Now I want to move this code to spring batch(I'm newbie to spring batch) Here are my question 1. In task, is it

How to terminate Step within a Spring Batch Split Flow with a Decider

杀马特。学长 韩版系。学妹 提交于 2019-12-01 21:38:08
I've happened up the following design defect in Spring Batch. A Step must have a Next attribute unless it is the last Step or last Step of a Split Flow. A Decider block must handle all cases returned by the Decider. Because of this, in a Split Flow, where the final Step would not have a Next attribute, if there is a Decider guarding it, then it must have a Next attribute. So it shouldn't have that attribute, but it also needs it. Catch 22. Example: <!-- Process parallel steps --> <split id="split01"> <flow> <step id="step1" next="step02"> <!-- Do something --> </step> <step id="step02"> <!--