In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
I. Job creation and its Application
Introduction to 1.Job flow:
(1) State machine: for example, to complete step1, whether to continue to complete step2,step3, we need to control it through Job flow
(2) demonstration: use the next () method to achieve sequential execution of step1,step2... , use the on (), to (), from () methods to achieve the same purpose as the next () method, and show the fail () method and the stopAndRestart () method again
Example 1: create a JobFlowDemoOne and have three Step execute sequentially using next ()
JobFlowDemOne:
Package com.dhcc.batch.batchDemo.config;import org.springframework.batch.core.Job;import org.springframework.batch.core.Step;import org.springframework.batch.core.StepContribution;import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;import org.springframework.batch.core.scope.context.ChunkContext;import org.springframework.batch.core.step.tasklet.Tasklet;import org.springframework.batch.repeat.RepeatStatus;import org.springframework.beans.factory.annotation.Autowired Import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;@Configurationpublic class JobFlowDemOne {@ Autowired private JobBuilderFactory jobBuilderFactory; @ Autowired private StepBuilderFactory stepBuilderFactory; @ Bean public Job JobFlowDemo1 () {return jobBuilderFactory.get ("JobFlowDemo1") .start (step1 ()) .next (step2 ()) .next (step3 ()) .build () } @ Bean public Step step1 () {return stepBuilderFactory.get ("step1") .tasklet (new Tasklet () {@ Override public RepeatStatus execute (StepContribution contribution, ChunkContext chunkContext) throws Exception {System.out.println ("step1-- > Hello Spring Batch...."); return RepeatStatus.FINISHED;}}) .build () } @ Bean public Step step2 () {return stepBuilderFactory.get ("step2") .tasklet ((contribution, context)-> {System.out.println ("step2-> Hello Spring Batch.."); return RepeatStatus.FINISHED;}) .build () } @ Bean public Step step3 () {return stepBuilderFactory.get ("step3") .tasklet (new Tasklet () {@ Override public RepeatStatus execute (StepContribution contribution, ChunkContext chunkContext) throws Exception {System.out.println ("step3-- > Hello Spring Batch...."); return RepeatStatus.FINISHED;}}) .build () }} in step2 (), we use the new features of java8, using the Lambda expression package com.dhcc.batch.batchDemo;import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication@EnableBatchProcessingpublic class BatchDemoApplication {public static void main (String [] args) {SpringApplication.run (BatchDemoApplication.class, args);}}
Start execution, and the execution result is:
Observing the execution result of the console, we can find that the Step1,step2,step3 has been executed in the order of next (). At this time, we enter the database for observation. We mainly observe the JobExecution table and the StepExecution table to view its table data:
JobExecution:
StepExecution:
Before viewing a JobInstance, observe the Job instance:
Example 2: we use the on (), to (), from () methods to execute our Step sequentially to achieve the same effect as example 1
The original code remains the same, so let's modify JobFlowDemo1 slightly (note: I created a new database here for the convenience of the demonstration):
@ Bean public Job JobFlowDemo2 () {return jobBuilderFactory.get ("JobFlowDemo2") / / .start (step1 ()) / / .next (step2 ()) / / .next (step3 ()) .start (step1 ()) .on ("COMPLETED") .to (step2 ()) .from (step2 ()) .on ("COMPLETED") ") .to (step3 ()) .from (step3 ()) .end () .build ()
Observation console:
The code was executed successfully
When we use the fail () method and the stopAndRestart () method later, we will learn more about it.
II. Creation and use of flow
Introduction to 1.flow:
(1) flow is a set of Step, which defines the conversion relationship between Step and Step.
(2) creating Flow can achieve the effect of reuse, which can be reused between different Job.
(3) use FlowBuilder to create a Flow, which is similar to Job, using start (), next () and end () to run flow
Example:
Create JobFlowDemoTwoApplication
Package com.dhcc.batch.batchDemo.jobFlowDemoTwo;import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication@EnableBatchProcessingpublic class JobFlowDemoTwoApplication {public static void main (String [] args) {SpringApplication.run (JobFlowDemoTwoApplication.class, args);}}
Create step,flow and Job-- "JobFlowDemoTwoConfiguration:
Package com.dhcc.batch.batchDemo.jobFlowDemoTwo;import org.springframework.batch.core.Job;import org.springframework.batch.core.Step;import org.springframework.batch.core.StepContribution;import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;import org.springframework.batch.core.job.builder.FlowBuilder;import org.springframework.batch.core.job.flow.Flow;import org.springframework.batch.core.scope.context.ChunkContext Import org.springframework.batch.core.step.tasklet.Tasklet;import org.springframework.batch.repeat.RepeatStatus;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;@Configurationpublic class JobFlowDemoTwoConfiguration {@ Autowired private JobBuilderFactory jobBuilderFactory; @ Autowired private StepBuilderFactory stepBuilderFactory @ Bean public Step jobFlowDemoTwo1 () {return stepBuilderFactory.get ("jobFlowDemoTwo1") .tasklet (new Tasklet () {@ Override public RepeatStatus execute (StepContribution contribution, ChunkContext chunkContext) throws Exception {System.out.println ("Hello-- > jobFlowDemoTwo1"); return RepeatStatus.FINISHED;}}) .build () } @ Bean public Step jobFlowDemoTwo2 () {return stepBuilderFactory.get ("jobFlowDemoTwo2") .tasklet (new Tasklet () {@ Override public RepeatStatus execute (StepContribution contribution, ChunkContext chunkContext) throws Exception {System.out.println ("Hello-- > jobFlowDemoTwo2"); return RepeatStatus.FINISHED;}}) .build () } @ Bean public Step jobFlowDemoTwo3 () {return stepBuilderFactory.get ("jobFlowDemoTwo3") .tasklet (new Tasklet () {@ Override public RepeatStatus execute (StepContribution contribution, ChunkContext chunkContext) throws Exception {System.out.println ("Hello-- > jobFlowDemoTwo3"); return RepeatStatus.FINISHED;}}) .build () } / / create Flow, which is a Step collection @ Bean public Flow jobFlowDemoFlow () {return new FlowBuilder ("jobFlowDemoFlow") .start (jobFlowDemoTwo1 ()) .next (jobFlowDemoTwo2 ()) .build () } / / create a Job to execute Flow and Step @ Bean public Job jobFlowDemoTwoJob () {return jobBuilderFactory.get ("jobFlowDemoTwoJob") .start (jobFlowDemoFlow ()) .next (jobFlowDemoTwo3 ()) .end () .build ();}}
To start running, let's observe the console:
As a result, we can see that Job first runs the two Step in Flow, and then runs jobFlowDemoStep3 (), in the same order as we set.
In the database, we take the stepExection table as an example:
See 3 Step sequential execution completed
Definition and use of spilt multithreaded concurrent tasks
1.Spilt executes Flow asynchronously
two。 Examples are as follows:
(1) first define two Flow, define some Step in each Flow, and each Step prints out its own name and the currently running thread.
(2) create a Job and start two Flow asynchronously using Spilt
(3) run Job to view the results
Example:
JobSpiltDemoApplication:
Package com.dhcc.batch.batchDemo.jobSpiltDemo;import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication@EnableBatchProcessingpublic class JobSpiltDemoApplication {public static void main (String [] args) {SpringApplication.run (JobSpiltDemoApplication.class, args);}}
JobSpiltDemoConfiguration:
Package com.dhcc.batch.batchDemo.jobSpiltDemo;import org.springframework.batch.core.Job;import org.springframework.batch.core.StepContribution;import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;import org.springframework.batch.core.job.builder.FlowBuilder;import org.springframework.batch.core.job.flow.Flow;import org.springframework.batch.core.scope.context.ChunkContext;import org.springframework.batch.core.step.tasklet.Tasklet Import org.springframework.batch.repeat.RepeatStatus;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import org.springframework.core.task.SimpleAsyncTaskExecutor;@Configurationpublic class JobSpiltDemoConfiguration {@ Autowired private JobBuilderFactory jobBuilderFactory; @ Autowired private StepBuilderFactory stepBuilderFactory / * create job to run Flow. We use split (new * SimpleAsyncTaskExecutor ()) .add () to make flow execute asynchronously. Multiple Flow * * @ return * / @ Bean public Job SpiltJob () {return jobBuilderFactory.get ("SpiltJob") .start (jobSpiltFlow1 ()) .split (new SimpleAsyncTaskExecutor ()) .add (jobSpiltFlow2 ()) .end () .build () can be added to add (). } / / create Flow1 @ Bean public Flow jobSpiltFlow1 () {return new FlowBuilder ("jobSpiltFlow1") .start (stepBuilderFactory.get ("jobSpiltStep1") .tasklet (tasklet ()) .build () .next (stepBuilderFactory.get ("jobSpiltStep2") .tasklet (tasklet ()) .build ()) .start () } / / create Flow1 @ Bean public Flow jobSpiltFlow2 () {return new FlowBuilder ("jobSpiltFlow2") .start (stepBuilderFactory.get ("jobSpiltStep3") .tasklet (tasklet ()) .build () .next (stepBuilderFactory.get ("jobSpiltStep4") .tasklet (tasklet ()) .build ()) .build ();} private Tasklet tasklet () {return new PrintTasklet () } / / the task class executed by step (can be written as external class, here we write as inner class for convenience) private class PrintTasklet implements Tasklet {@ Override public RepeatStatus execute (StepContribution contribution, ChunkContext chunkContext) throws Exception {System.out.println ("has been execute on stepName:" + chunkContext.getStepContext (). GetStepName () + ", has been execute on thread:" + Thread.currentThread () .getName () Return RepeatStatus.FINISHED;}
Running result:
Looking at the console, we can see that we have achieved the goal of letting Step execute asynchronously
Observe the database table:
Four. definition and application of decision maker
1.Decision: provide us with a conditional decision on which Step to execute next
2.JobExecutionDecider: interface to provide decision conditions
Example:
Package com.dhcc.batch.batchDemo.flowDecisionDemo;import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication@EnableBatchProcessingpublic class FlowDecisionDemoApplication {public static void main (String [] args) {SpringApplication.run (FlowDecisionDemoApplication.class, args);}}
FlowDecisionDemoConfiguration:
Package com.dhcc.batch.batchDemo.flowDecisionDemo;import org.springframework.batch.core.Job;import org.springframework.batch.core.Step;import org.springframework.batch.core.StepContribution;import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;import org.springframework.batch.core.job.flow.JobExecutionDecider;import org.springframework.batch.core.scope.context.ChunkContext;import org.springframework.batch.core.step.tasklet.Tasklet;import org.springframework.batch.repeat.RepeatStatus Import org.springframework.beans.factory.annotation.Autowired;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;@Configurationpublic class FlowDecisionDemoConfiguration {@ Autowired private JobBuilderFactory jobBuilderFactory; @ Autowired private StepBuilderFactory stepBuilderFactory / / write Job @ Bean public Job FlowDecisionJob () {return jobBuilderFactory.get ("FlowDecisionJob") .start (firstStep ()) .next (myDecider ()) .from (myDecider ()) .on ("EVEN") .to (evenStep ()) .from (myDecider ()) .on ("ODD") .to (oddStep ()) .from (oddStep ()) .on ("*") .to (myDecider ()) .end () .build () } @ Bean public Step firstStep () {return stepBuilderFactory.get ("firstStep") .tasklet (new Tasklet () {@ Override public RepeatStatus execute (StepContribution contribution, ChunkContext chunkContext) throws Exception {System.out.println ("Hello firstStep.."); return RepeatStatus.FINISHED;}}) .build () } @ Bean public Step evenStep () {return stepBuilderFactory.get ("evenStep") .tasklet (new Tasklet () {@ Override public RepeatStatus execute (StepContribution contribution, ChunkContext chunkContext) throws Exception {System.out.println ("Hello evenStep.."); return RepeatStatus.FINISHED;}}) .build () } @ Bean public Step oddStep () {return stepBuilderFactory.get ("oddStep") .tasklet (new Tasklet () {@ Override public RepeatStatus execute (StepContribution contribution, ChunkContext chunkContext) throws Exception {System.out.println ("Hello oddStep.."); return RepeatStatus.FINISHED;}}) .build () } / / decision maker @ Bean public JobExecutionDecider myDecider () {return new myDecider ();}}
MyDecider:
Package com.dhcc.batch.batchDemo.flowDecisionDemo;import org.springframework.batch.core.JobExecution;import org.springframework.batch.core.StepExecution;import org.springframework.batch.core.job.flow.FlowExecutionStatus;import org.springframework.batch.core.job.flow.JobExecutionDecider;public class myDecider implements JobExecutionDecider {private int count=0; @ Override public FlowExecutionStatus decide (JobExecution jobExecution, StepExecution stepExecution) {count++; if (count%2==0) {return new FlowExecutionStatus ("EVEN") } else {return new FlowExecutionStatus ("ODD");}
Running result:
We observe the console and analyze the results: first, run firstStep () in job, then enter Count++, in myDecider at this time count=1, return "ODD", execute oddStep () in job, and then no matter what state enters the myDecider again, at this time count=2, so return "EVEN", and next execute evenStep ()
5. Nested definition and Application of Job
1.job can be used nested, nested Job we call it a child job, nested Job we call it a parent job
two。 A parent Job can have multiple child Job
3. The child job cannot be run alone, and its parent Job is required to start it
Example:
NestedJobApplication:
Package com.dhcc.batch.batchDemo.nestedJob;import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication@EnableBatchProcessingpublic class NestedJobApplication {public static void main (String [] args) {SpringApplication.run (NestedJobApplication.class, args);}}
Next, set up two child Job, with two Step and a parent job in each child job
Let the parent job control the running child job
ChildJobOneConfiguration:
Package com.dhcc.batch.batchDemo.nestedJob;import org.springframework.batch.core.Job;import org.springframework.batch.core.Step;import org.springframework.batch.core.StepContribution;import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;import org.springframework.batch.core.scope.context.ChunkContext;import org.springframework.batch.core.step.tasklet.Tasklet;import org.springframework.batch.repeat.RepeatStatus;import org.springframework.beans.factory.annotation.Autowired Import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;@Configurationpublic class ChildJobOneConfiguration {@ Autowired private JobBuilderFactory jobBuilderFactory; @ Autowired private StepBuilderFactory stepBuilderFactory; @ Bean public Job childJob1 () {return jobBuilderFactory.get ("childJob1") .start (childJob1Step1 ()) .next (childJob1Step2 ()) .build () } @ Bean public Step childJob1Step1 () {return stepBuilderFactory.get ("childJob1Step1") .tasklet (new Tasklet () {@ Override public RepeatStatus execute (StepContribution contribution, ChunkContext chunkContext) throws Exception {System.out.println ("Hello---- > childJob1Step1"); return RepeatStatus.FINISHED;}}) .build () @ Bean public Step childJob1Step2 () {return stepBuilderFactory.get ("childJob1Step2") .tasklet (new Tasklet () {@ Override public RepeatStatus execute (StepContribution contribution, ChunkContext chunkContext) throws Exception {System.out.println ("Hello---- > childJob1Step2"); return RepeatStatus.FINISHED;}}) .build ();}}
ChildJobTwoConfiguration:
Package com.dhcc.batch.batchDemo.nestedJob;import org.springframework.batch.core.Job;import org.springframework.batch.core.Step;import org.springframework.batch.core.StepContribution;import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;import org.springframework.batch.core.scope.context.ChunkContext;import org.springframework.batch.core.step.tasklet.Tasklet;import org.springframework.batch.repeat.RepeatStatus;import org.springframework.beans.factory.annotation.Autowired Import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;@Configurationpublic class ChildJobTwoConfiguration {@ Autowired private JobBuilderFactory jobBuilderFactory; @ Autowired private StepBuilderFactory stepBuilderFactory; @ Bean public Job childJob2 () {return jobBuilderFactory.get ("childJob2") .start (childJob2Step1 ()) .next (childJob2Step2 ()) .build () } @ Bean public Step childJob2Step1 () {return stepBuilderFactory.get ("childJob2Step1") .tasklet (new Tasklet () {@ Override public RepeatStatus execute (StepContribution contribution, ChunkContext chunkContext) throws Exception {System.out.println ("Hello---- > childJob2Step1"); return RepeatStatus.FINISHED;}}) .build () @ Bean public Step childJob2Step2 () {return stepBuilderFactory.get ("childJob2Step2") .tasklet (new Tasklet () {@ Override public RepeatStatus execute (StepContribution contribution, ChunkContext chunkContext) throws Exception {System.out.println ("Hello---- > childJob2Step2"); return RepeatStatus.FINISHED;}}) .build ();}}
ParentJobConfiguration:
Package com.dhcc.batch.batchDemo.nestedJob;import org.springframework.batch.core.Job;import org.springframework.batch.core.Step;import org.springframework.batch.core.StepContribution;import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;import org.springframework.batch.core.launch.JobLauncher;import org.springframework.batch.core.repository.JobRepository;import org.springframework.batch.core.scope.context.ChunkContext;import org.springframework.batch.core.step.builder.JobStepBuilder Import org.springframework.batch.core.step.builder.StepBuilder;import org.springframework.batch.core.step.tasklet.Tasklet;import org.springframework.batch.repeat.RepeatStatus;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import org.springframework.transaction.PlatformTransactionManager;@Configurationpublic class ParentJobConfiguration {@ Autowired private JobBuilderFactory jobBuilderFactory; @ Autowired private StepBuilderFactory stepBuilderFactory; @ Autowired private Job childJob1; @ Autowired private Job childJob2 @ Autowired private JobLauncher jobLauncher; @ Bean public Job parentJob (JobRepository repository,PlatformTransactionManager transactionManager) {return jobBuilderFactory.get ("parentJob") .start (parentJobStep ()) .next (childJob1 (repository, transactionManager)) .Next (childJob2 (repository, transactionManager)) .build () } private Step childJob1 (JobRepository repository,PlatformTransactionManager transactionManager) {return new JobStepBuilder (new StepBuilder ("childJob1")) .job (childJob1) .launcher (jobLauncher) .repository (repository) .transactionManager (transactionManager) .build () } private Step childJob2 (JobRepository repository,PlatformTransactionManager transactionManager) {return new JobStepBuilder (new StepBuilder ("childJob2")) .job (childJob2) .launcher (jobLauncher) .repository (repository) .transactionManager (transactionManager) .build () } @ Bean public Step parentJobStep () {return stepBuilderFactory.get ("parentJobStep") .tasklet (new Tasklet () {@ Override public RepeatStatus execute (StepContribution contribution, ChunkContext chunkContext) throws Exception {System.out.println ("Helllo- > parentJobStep.."); return RepeatStatus.FINISHED }) .build ();}}
Add to the configuration file
Spring.datasource.url=jdbc:mysql://localhost:3306/springbatch?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8&useSSL=falsespring.datasource.username=rootspring.datasource.password=qitao1996spring.datasource.driver-class-name=com.mysql.jdbc.Driverspring.datasource.schema=classpath:/org/springframework/batch/core/schema-mysql.sqlspring.batch.initialize-schema=alwaysspring.batch.job.names=parentJob
Running result:
Observe the console and run it successfully. We have achieved the effect of job nesting.
VI. Definition and application of listeners
1.Listener: a way to control the execution of Job
two。 Listeners can be implemented through interfaces or annotations
3. Provide listener interfaces at all levels in spring-batch, from job level to item level
(1) JobExecutionListener (before..,after..)
(2) StepExecutionListener (before..,after..)
(3) ChunkListener (before..,after..)
(4) ItemReaderListener;ItemWriterListener;ItemProcessListener (before..,after..,error..)
Example:
ListenerJobApplication:
Package com.dhcc.batch.batchDemo.listenerJob;import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication@EnableBatchProcessingpublic class ListenerJobApplication {public static void main (String [] args) {SpringApplication.run (ListenerJobApplication.class, args);}}
Create a listener (implemented by implementing an interface)
MyJobListener:
Package com.dhcc.batch.batchDemo.listenerJob;import org.springframework.batch.core.JobExecution;import org.springframework.batch.core.JobExecutionListener;/** * implement interface construction listener * @ author Administrator * * / public class MyJobListener implements JobExecutionListener {@ Override public void beforeJob (JobExecution jobExecution) {System.out.println (jobExecution.getJobInstance (). GetJobName () + "before running.") @ Override public void afterJob (JobExecution jobExecution) {System.out.println (jobExecution.getJobInstance () .getJobName () + "before running.");}}
Create a listener (implemented by annotations)
MyChunkListener:
Package com.dhcc.batch.batchDemo.listenerJob;import org.springframework.batch.core.annotation.AfterChunk;import org.springframework.batch.core.annotation.BeforeChunk;import org.springframework.batch.core.scope.context.ChunkContext;/** * use annotations to build listeners * @ author Administrator * * / public class MyChunkListener {@ BeforeChunk public void beforeChunk (ChunkContext context) {System.out.println (context.getStepContext (). GetStepName () + "chunk before running.") @ AfterChunk public void afterChunk (ChunkContext context) {System.out.println (context.getStepContext () .getStepName () + "chunk after running.");}}
MyListenerJobConfiguration:
Package com.dhcc.batch.batchDemo.listenerJob;import java.util.Arrays;import java.util.List;import org.springframework.batch.core.Job;import org.springframework.batch.core.Step;import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;import org.springframework.batch.item.ItemReader;import org.springframework.batch.item.ItemWriter;import org.springframework.batch.item.support.ListItemReader;import org.springframework.beans.factory.annotation.Autowired Import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;@Configurationpublic class MyListenerJobConfiguration {@ Autowired private JobBuilderFactory jobBuilderFactory; @ Autowired private StepBuilderFactory stepBuilderFactory; / / listen for Job execution @ Bean public Job myListenerJob () {return jobBuilderFactory.get ("myListenerJob") .start (myListenerStep ()) .listener (new MyJobListener ()) .build () } private Step myListenerStep () {return stepBuilderFactory.get ("myListenerStep") .chunk (2) .faultTolerant () .listener (new MyChunkListener ()) .reader (reader ()) .writer (writer ()) .build ();} private ItemReader
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.