spring-batch

Spring Batch -Remote partitioning

风流意气都作罢 提交于 2021-02-08 03:59:25
问题 Currently we are migrating a batch job from java to spring batch.This batch job gets its input from database and web service. We need to run this job in four servers for an increased performance as this job is handling huge data. Is the above scenario is achievable through remote partitioning in spring batch? I went through remote partitioning documents but its difficult to understand and I did n't find any solid examples in remote partitioning. Please help me on this. 回答1: Yes, what you are

pass job parameters to custom writer Spring batch

雨燕双飞 提交于 2021-02-08 03:47:41
问题 I have a custom writer with a FlatFileItemWriter and i want to pass a job parameter( a output file) defined in the main class How can i deal with this ? Thank you very much CustomWriter public class PersonItemWriter implements ItemWriter<Person> { private FlatFileItemWriter<String> flatFileItemWriter = new FlatFileItemWriter<String>(); private Resource resource; @Override public void write(List<? extends Person> personList) throws Exception { flatFileItemWriter.setResource(new

pass job parameters to custom writer Spring batch

ⅰ亾dé卋堺 提交于 2021-02-08 03:46:24
问题 I have a custom writer with a FlatFileItemWriter and i want to pass a job parameter( a output file) defined in the main class How can i deal with this ? Thank you very much CustomWriter public class PersonItemWriter implements ItemWriter<Person> { private FlatFileItemWriter<String> flatFileItemWriter = new FlatFileItemWriter<String>(); private Resource resource; @Override public void write(List<? extends Person> personList) throws Exception { flatFileItemWriter.setResource(new

Spring Batch error (A Job Instance Already Exists) and RunIdIncrementer generates only once

送分小仙女□ 提交于 2021-02-07 20:12:54
问题 i'm using Spring Batch & Quartz to read from database table and write in another table. the database is Oracle and it is c3p0 the problem is each job must have a unique parameters, I tried RunIdIncrementer and I tried this code: public class JobRerunner implements JobParametersIncrementer { @Override public JobParameters getNext(JobParameters parameters) { System.out.println("got job parameters: " + parameters); if (parameters==null || parameters.isEmpty()) { return new JobParametersBuilder()

Spring Batch error (A Job Instance Already Exists) and RunIdIncrementer generates only once

空扰寡人 提交于 2021-02-07 20:00:53
问题 i'm using Spring Batch & Quartz to read from database table and write in another table. the database is Oracle and it is c3p0 the problem is each job must have a unique parameters, I tried RunIdIncrementer and I tried this code: public class JobRerunner implements JobParametersIncrementer { @Override public JobParameters getNext(JobParameters parameters) { System.out.println("got job parameters: " + parameters); if (parameters==null || parameters.isEmpty()) { return new JobParametersBuilder()

How to use spring batch to parse fixed length formats Files (File Without any delimiter)

巧了我就是萌 提交于 2021-02-07 18:27:28
问题 how to Configure spring-batch reader for fixed length formats Files (File Without any delimiter). Each element is determined in relation to its starting and ending position. Sample of line : 120180208FAILED 220180208SUCCES 120170208SUCCES 1 : code , 20180208 : date ,FAILED : status 回答1: you can use FixedLengthTokenizer reader for this. This is how you can configure FixedLengthTokenizer . Sample Text file UK21341EAH4121131.11customer1 UK21341EAH4221232.11customer2 UK21341EAH4321333.11customer3

Spring Batch How to read multiple table (queries) as Reader and write it as flat file write

戏子无情 提交于 2021-02-07 17:23:19
问题 In my project I have read multiple tables with different queries and consolidate those results sets in flat files. How do I achieve that. I mean JdbcReader is directly taking 1 select query, how can I customize it. 回答1: If JdbcCursorItemReader does not suit your needs, you are always free to implement a custom reader by implementing the ItemReader interface. public interface ItemReader<T> { T read() throws Exception, UnexpectedInputException, ParseException; } Just write a class that

Spring Batch using Spring Boot - Never retry on write error

陌路散爱 提交于 2021-02-07 14:42:10
问题 I created a batch using Spring Boot. Here is the main configuration class of the batch : @Configuration @EntityScan({"my.domain"}) @EnableJpaRepositories({"my.domain"}) @EnableBatchProcessing public class BatchConfiguration { /** Motif d'identification des fichiers d'entrée */ @Value("${batch.input-file-pattern}") private String inputFilePattern; @Bean public BatchConfigurer configurer( EntityManagerFactory entityManagerFactory ){ return new MapForcedBatchConfigurer( entityManagerFactory ); }

Spring Batch - How to prevent database commits with jobLauncherTestUtils

大兔子大兔子 提交于 2021-02-07 12:55:50
问题 I have Spring Batch job that writes to the database (it has a step with a JpaItemWriter ). I have an integration test such as follows: @RunWith(SpringRunner.class) @SpringBootTest @ActiveProfiles("integrationTest") public class LoadApplicationTests { @Autowired private Job job; @Autowired private JobRepository jobRepository; @Autowired private JobLauncher jobLauncher; private JobLauncherTestUtils jobLauncherTestUtils; @Before public void setUp() throws IOException, java.text.ParseException,

spring integration : solutions/tips on connect multiple sftp server?

☆樱花仙子☆ 提交于 2021-02-07 10:46:19
问题 My spring batch project needs to download files from multiple sftp servers. the sftp host/port/filePath is config in application.properties file. I consider using the spring integration 'sftp out-bound gateway' to connect these servers and download files. but Im don't how to do this kind of configuration(I'm using java config, ) and make it work? i guess I need some way to define multiple session factory according to the number of sftp server info config in application.properties file.