spring-batch

How to configure a Spring batch job with single reader and calling multiple writers depending on object returned

核能气质少年 提交于 2019-12-07 17:01:14
问题 Below is the job file currently i'm using. <batch:job id="job1"> <batch:step id="step1"> <batch:tasklet> <batch:chunk reader="reader" processor="processor" writer="ItemWriter" commit-interval="3"> </batch:chunk> </batch:tasklet> </batch:step> </batch:job> 回答1: As was said in the Luca's comment, you can use a ClassifierCompositeItemWriter which needs a org.springframework.classify.Classifier . One of the few implementations of the latter is org.springframework.classify

Spring Batch with multi tenancy

心已入冬 提交于 2019-12-07 15:24:55
问题 How do we define spring batch jobs to run against multiple tenants? I have setup to run a sequence of jobs in order every night against one database schema currently. All the jobs currently read files from a location and insert to database.The batch configuration was very basic where I defined a data-source, transaction manager and mapped job-repository to it. My jobs will point to this repository and transaction manager. Also I am currently persisting batch meta data information in database.

org.springframework.batch.item.ReaderNotOpenException: Reader must be open before it can be read

China☆狼群 提交于 2019-12-07 15:24:41
问题 i'm using Spring batch to run (reading from database table and writing into another table) job the job is scheduled by Quartz and the database is oracle and it's c3p0, i'm getting reader not open exception this is the job context <batch:job id="readyReqPoolJob"> <batch:step id="readyReqPoolStep"> <batch:tasklet> <batch:chunk reader="readyReqPoolReader" writer="readyReqPoolWrtiter" commit-interval="1000" /> </batch:tasklet> </batch:step> </batch:job> <!-- ======================================

Spring Batch: Horizontal scaling of Job Repository

依然范特西╮ 提交于 2019-12-07 15:12:26
I read a lot about how to enable parallel processing and chunking of an individual job, using Master/Slave paradigm. Consider an already implemented Spring Batch solution that was intended to run on a standalone server. With minimal refactoring I would like to enable this to horizontally scale and be more resilient in production operation. Speed and efficiency is not a goal. http://www.mkyong.com/spring-batch/spring-batch-hello-world-example/ In the following example a Job Repository is used that connects to an initializes a database schema for the Job Repository. Job initiation requests are

Java application: Sequence workflow pattern

左心房为你撑大大i 提交于 2019-12-07 15:00:37
问题 I have a spring web application. When a user calls save endpoint, system should execute many external calls to save the state in multiple microservices. However, those steps depend on each other. In other words I have a sequence of steps to perform. sequence pattern Just calling a set of steps one by one is not a big deal, I can just create class for each step and call them one by one doing appropriate modifications between the steps. However, each of the steps can fail and if it happens it

How to read and process multiple files concurrently in spring?

陌路散爱 提交于 2019-12-07 14:28:00
问题 I am new to Spring framework and I am doing one simple project using spring and got stuck in between. In my project I am reading the file from directory using spring poller. And then processing that file through various channels and sending it to the queue. But problem is that "file-inbound-channel-adapter" (which I'm using ) is reading only one file at a time. So I need a solution which will read and process multiple files at a time. Is there any way to implement multithreading in spring

how to create a report on filtered items in spring-batch?

吃可爱长大的小学妹 提交于 2019-12-07 10:29:18
问题 I basically want to create a report with the items that were filtered out in every step in my batch. Currently I can see how many were filtered (and skipped) with spring-batch-admin, but I want the list of items so I can take care of them manually. My step runs over a list of clients and brings data on them from a 3rd party source. I have username+password for every account which I use to get the data. It's possible for a client not to have credentials. I filter those before I run the

Spring Batch restart uncompleted jobs from the same execution and step

强颜欢笑 提交于 2019-12-07 10:25:04
问题 I use the following logic to restart the Spring Batch uncompleted(for example after application abnormal termination) jobs: public void restartUncompletedJobs() { LOGGER.info("Restarting uncompleted jobs"); try { jobRegistry.register(new ReferenceJobFactory(documetPipelineJob)); List<String> jobs = jobExplorer.getJobNames(); for (String job : jobs) { Set<JobExecution> runningJobs = jobExplorer.findRunningJobExecutions(job); for (JobExecution runningJob : runningJobs) { runningJob.setStatus

Using JdbcPagingItemReader causing join statements causing MySQLIntegrityConstraintViolationException

时光毁灭记忆、已成空白 提交于 2019-12-07 09:59:09
问题 I am running Spring Batch and using JdbcPagingItemReader . With a sample config of : <bean id="dogQueryProvider" class="org.springframework.batch.item.database.support.SqlPagingQueryProviderFactoryBean"> <property name="databaseType" value="mysql" /> <property name="dataSource" ref="dataSource" /> <property name="selectClause" value="SELECT owner.id as ownerid, first_name, last_name, dog_name " /> <property name="fromClause" value="FROM dog_owner owner INNER JOIN dog ON owner.id = dog.id " />

Can't get spring batch conditional flows working

社会主义新天地 提交于 2019-12-07 09:46:40
问题 I'm having trouble getting a conditional spring batch flow to work using java config. The samples I've seen in spring batch samples, or spring batch's test code, or on stack overflow tend to show a conditional where a single step needs to be executed on condition, or it's the final step, or both. That's not the case I need to solve. In procedural pseudo code, I want it to behave like initStep() if decision1() subflow1() middleStep() if decision2() subflow2() lastStep() So, subflow1 and 2 are