spring-batch 集成
批作业运行
<!--用于在Spring中对已经注册的批作业任务的收集器-->
<bean id="batchJobRegistry" class="org.springframework.batch.core.configuration.support.MapJobRegistry"/>
<!--声明用于浏览批作业执行情况的资源浏览器-->
<bean id="batchJobExplorer" class="org.springframework.batch.core.explore.support.JobExplorerFactoryBean">
<property name="dataSource" ref="defaultDataSource"/>
</bean>
<!--声明批作业的异步执行服务类-->
<bean id="batchJobAsynLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
<property name="jobRepository" ref="jobRepository"/>
<property name="taskExecutor">
<bean class="com.halo.core.batch.support.AsyncJobExecutor"/>
</property>
</bean>
<!--声明批作业的同步执行服务类-->
<bean id="batchJobSynLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
<property name="jobRepository" ref="jobRepository"/>
<property name="taskExecutor">
<bean class="org.springframework.core.task.SyncTaskExecutor"/>
</property>
</bean>
<!--带有逻辑判断的批作业执行器-->
<bean id="batchJobLauncher" class="com.halo.core.batch.service.impl.batch.BatchJobLauncher"/>
<!--可用于批作业创建重复实例的计数器-->
<bean id="batchJobIncrementer" class="org.springframework.batch.core.launch.support.RunIdIncrementer"/>
<!--默认的批作业管理工具-->
<bean id="batchJobManager" class="org.springframework.batch.core.launch.support.SimpleJobOperator">
<property name="jobExplorer" ref="batchJobExplorer"/>
<property name="jobLauncher" ref="batchJobAsynLauncher"/>
<property name="jobRepository" ref="jobRepository"/>
<property name="jobRegistry" ref="batchJobRegistry"/>
</bean>
<!--可同步运行的批作业管理工具-->
<bean id="synBatchJobManager" class="org.springframework.batch.core.launch.support.SimpleJobOperator">
<property name="jobExplorer" ref="batchJobExplorer"/>
<property name="jobLauncher" ref="batchJobSynLauncher"/>
<property name="jobRepository" ref="jobRepository"/>
<property name="jobRegistry" ref="batchJobRegistry"/>
</bean>
<!--可异步运行的批作业管理工具-->
<bean id="asynBatchJobManager" class="org.springframework.batch.core.launch.support.SimpleJobOperator">
<property name="jobExplorer" ref="batchJobExplorer"/>
<property name="jobLauncher" ref="batchJobAsynLauncher"/>
<property name="jobRepository" ref="jobRepository"/>
<property name="jobRegistry" ref="batchJobRegistry"/>
</bean>批作业重启
批作业触发
Last updated