从头认识SpringBatch批处理框架---JobRepository数据库存储元数据并分析存储元数据表

本文深入探讨SpringBatch的JobRepository,重点介绍其在数据库中存储元数据的机制。内容包括MapJobRepositoryFactoryBean的默认实现,以及schema-mysql.sql中的建表语句,如BATCH_JOB_INSTANCE、BATCH_JOB_EXECUTION_PARAMS等关键表的数据结构分析。此外,文章还提及BATCH_JOB_EXECUTION和BATCH_STEP_EXECUTION表的详细信息,为理解SpringBatch执行流程提供帮助。
摘要由CSDN通过智能技术生成
               

JobRepository存储执行期的元数据,提供两种默认实现,一种是存放在内存中,默认实现类为:MapJobRepositoryFactoryBean。在xml中的配置如下:

<bean id="jobRepository"   class="org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean"> </bean>

另一种是存入数据库中,可以随时监控批处理Job的执行状态,查看Job执行结果是成功还是失败,并且使得在Job失败的情况下重新启动Job成为可能。具体配置如下:

<?xml version="1.0" encoding="UTF-8"?><bean:beans xmlns="http://www.springframework.org/schema/batch"        xmlns:bean="http://www.springframework.org/schema/beans"     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"        xmlns:p="http://www.springframework.org/schema/p"     xmlns:tx="http://www.springframework.org/schema/tx"        xmlns:aop="http://www.springframework.org/schema/aop"     xmlns:context="http://www.springframework.org/schema/context"        xsi:schemaLocation="http://www.springframework.org/schema/beans     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd      http://www.springframework.org/schema/tx     http://www.springframework.org/schema/tx/spring-tx-3.0.xsd      http://www.springframework.org/schema/aop     http://www.springframework.org/schema/aop/spring-aop-3.0.xsd      http://www.springframework.org/schema/context     http://www.springframework.org/schema/context/spring-context-2.5.xsd    http://www.springframework.org/schema/batch     http://www.springframework.org/schema/batch/spring-batch-2.2.xsd">  <!-- 作业仓库 --> <job-repository id="jobRepository" data-source="dataSource"     transaction-manager="transactionManager" isolation-level-for-create="SERIALIZABLE"     table-prefix="BATCH_" max-varchar-length="1000" />  <!-- 作业调度器 --> <bean:bean id="jobLauncher"   class="org.springframework.batch.core.launch.support.SimpleJobLauncher">  <bean:property name="jobRepository" ref="jobRepository"/> </bean:bean>  <!-- 事务管理器 -->
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值