门户网站建设工作,如何确定竞争对手网站,产品宣传推广方案,wordpress 主题切换前言
在数字化转型的浪潮中#xff0c;任务调度成为了后端服务不可或缺的一部分。XXL-JOB 是一个轻量级、分布式的任务调度框架#xff0c;广泛应用于各种业务场景。达梦数据库#xff08;DM#xff09;#xff0c;作为一款国内领先的数据库产品#xff0c;已经被越来越…前言
在数字化转型的浪潮中任务调度成为了后端服务不可或缺的一部分。XXL-JOB 是一个轻量级、分布式的任务调度框架广泛应用于各种业务场景。达梦数据库DM作为一款国内领先的数据库产品已经被越来越多的企业采用。本文将介绍如何将 XXL-JOB 适配到达梦数据库实现任务调度的国产化支持。
Nacos 配置管理介绍
Nacos 提供了配置管理功能支持动态配置更新使得微服务架构中的配置管理更加灵活和高效。
达梦数据库介绍
达梦数据库是一款关系型数据库管理系统具有高性能、高可用性、易于维护等特点广泛应用于政府、金融、电信等行业。
环境准备
在开始之前请确保已经准备好以下环境
XXL-JOB下载 XXL-JOB 的最新版本。并构建 达梦数据库安装并启动达梦数据库。 mysql上的xxl-job库 迁移到达梦数据库上 最好使用传输工具进行传输 避免不必要用的问题 JDK确保已安装 JDK 1.8 或以上版本。
xxl-job适配人大金仓
特此说明 当前修改的xxl-job版本 为 2.4.1-SNAPSHOT
源码修改
pom中新增依赖 DmJdbcDriver18 驱动 注意版本
!-- dameng --
dependencygroupIdcom.dameng/groupIdartifactIdDmJdbcDriver18/artifactIdversion8.1.3.140/version
/dependency注释掉 原有的MySQL驱动
修改xxl-job 数据库连接以及账号密码 还有驱动类
## 注释掉原有的数据库配置
spring.datasource.urljdbc:dm://dm连接IP:5236/xxl_job?useUnicodetruecharacterEncodingUTF-8autoReconnecttrueserverTimezoneAsia/Shanghai
spring.datasource.usernamexxx
spring.datasource.passwordxxx
spring.datasource.driver-class-namedm.jdbc.driver.DmDriver数据库连接 配置没问题的话 应该就可以启动了
问题汇总
Caused by: dm.jdbc.driver.DMException: 第12 行附近出现错误:无效的表或视图名[xxl_job.xxl_job_log]
com.xxl.job.admin.core.thread.JobFailMonitorHelper#start 的41行 提示 xxl_job_log 表不存在 刚开始以为也需要添加库名 然后尝试加了 启动依然报错
后续查询资料 是 不支持 这个符号 解决 全局替换 xml中的 这个符号即可 示例
!-- 修改前 --
select idfindFailJobLogIds resultTypelongSELECT idFROM xxl_job.xxl_job_logWHERE !((trigger_code in (0, 200)and handle_code 0)OR(handle_code 200))AND alarm_status 0ORDER BY id ASCLIMIT #{pagesize}
/select
!-- 修改后 --
select idfindFailJobLogIds resultTypelongSELECT idFROM xxl_job.xxl_job_logWHERE !((trigger_code in (0, 200)and handle_code 0)OR(handle_code 200))AND alarm_status 0ORDER BY id ASCLIMIT #{pagesize}
/select后续 全局替换 xml中的 这个符号即可 函数 DATE ADD(unknown . interval不存在
com.xxl.job.admin.core.thread.JobRegistryHelper#start 66行 报错 ListInteger ids XxlJobAdminConfig.getAdminConfig().getXxlJobRegistryDao().findDead(RegistryConfig.DEAD_TIMEOUT, new Date());
提示 bad SOL grammar 错误函数 DATE ADD(unknown . interval不存在 Hint没有匹配指定名称和参数类型的函数. 您也许需要增加明确的类型转换.
解决- 替换新的实现方式 查询资料说是替换 新的实现方式 尝试多次 均不可 DATE_ADD(#{nowTime},INTERVAL -#{timeout} SECOND) 为
date ${nowTime} - INTERVAL ${timeout} second类似的修改 等等
官方的地址说明 ’ date_add 函数若对添加时间间隔的表达式进行求值可采用 DM 的 TIMESTAMPADD 函数进行替代例子如下 --MySQL
select DATE_ADD(sysdate(), INTERVAL 1 YEAR);
--2020-07-02 11:24:18
-- DM
select TIMESTAMPADD(SQL_TSI_YEAR, 1,sysdate());
--2020-07-02 11:27:56.000000直接看终极解决办法 替换现有实现 本质来讲就是需要个工具类 将传入的时间减去一个传入的 秒数 返回修改后的时间
直接在工具类com.xxl.job.core.util.DateUtil 中 添加 如下方法
public static Date addSeconds(final Date date, final int amount) {return add(date, Calendar.SECOND, amount);
}然后在 com.xxl.job.admin.dao.XxlJobRegistryDao 新增两个dao的方法
public ListInteger findDeadByTime(Param(nowTime) Date nowTime);public ListXxlJobRegistry findAllByTime(Param(nowTime) Date nowTime);在mapper文件 XxlJobRegistryMapper.xml 中 新增两个方法对应的sql 内容
select idfindDeadByTime resultTypejava.lang.IntegerSELECT include refidBase_Column_List /FROM xxl_job.xxl_job_registry AS tWHERE t.update_time ![CDATA[ ]] #{nowTime}
/select!-- 2024年09月12日16:26:10 新修改
注意 resultMap 是 map映射 XxlJobRegistry 而不是一个实体类
否则导致结果集部分参数获取不到--
select idfindAllByTime resultMapXxlJobRegistrySELECT include refidBase_Column_List /FROM xxl_job.xxl_job_registry AS tWHERE t.update_time #{nowTime}
/select最后在 com.xxl.job.admin.core.thread.JobRegistryHelper#registryMonitorThread 文件中替换实现
//ListInteger ids XxlJobAdminConfig.getAdminConfig().getXxlJobRegistryDao().findDead(RegistryConfig.DEAD_TIMEOUT, new Date());
//新增修改后的内容
Date beforeDate DateUtil.addSeconds(new Date(), -1 * RegistryConfig.DEAD_TIMEOUT);
ListInteger ids XxlJobAdminConfig.getAdminConfig().getXxlJobRegistryDao().findDeadByTime(beforeDate);
if (ids!null ids.size()0) {XxlJobAdminConfig.getAdminConfig().getXxlJobRegistryDao().removeDead(ids);
}// fresh online address (admin/executor)
HashMapString, ListString appAddressMap new HashMapString, ListString();
//ListXxlJobRegistry list XxlJobAdminConfig.getAdminConfig().getXxlJobRegistryDao().findAll(RegistryConfig.DEAD_TIMEOUT, new Date());
//新增的内容
Date nowDate DateUtil.addSeconds(new Date(), -1 * RegistryConfig.DEAD_TIMEOUT);
ListXxlJobRegistry list XxlJobAdminConfig.getAdminConfig().getXxlJobRegistryDao().findAllByTime(nowDate);com.xxl.job.admin.controller.JobGroupController#findRegistryByAppName 方法中 修改为使用 findAllByTime 方法
Date nowDate DateUtil.addSeconds(new Date(), -1 * RegistryConfig.DEAD_TIMEOUT);
ListXxlJobRegistry list xxlJobRegistryDao.findAllByTime(nowDate);注意事项
注意dm Caused by: dm.jdbc.driver.DMException: 第12 行附近出现错误:无效的表或视图名[xxl_job.xxl_job_log]
这个报错 不一定是这个表不存在 可能具体的位置的SQL语法有问题 导致这个报错
驱动连接问题
使用正确的驱动 或者直接去dm的安装目录下查找需要使用的版本 再使用jdk8的时候 可以使用DmJdbcDriver18 *达梦8 JDBC驱动版本说明 DmJdbcDriver16 实现JDBC 4.0标准接口已在JDK6上验证相关功能DmJdbcDriver17 实现JDBC 4.1标准接口已在JDK7上验证相关功能DmJdbcDriver18 实现JDBC 4.2标准接口已在JDK8JDK11JDK17上验证相关功能 good day 文章转载自: http://www.morning.mprpx.cn.gov.cn.mprpx.cn http://www.morning.kmjbs.cn.gov.cn.kmjbs.cn http://www.morning.skmpj.cn.gov.cn.skmpj.cn http://www.morning.bftqc.cn.gov.cn.bftqc.cn http://www.morning.brscd.cn.gov.cn.brscd.cn http://www.morning.lwwnq.cn.gov.cn.lwwnq.cn http://www.morning.tqrjj.cn.gov.cn.tqrjj.cn http://www.morning.ftzll.cn.gov.cn.ftzll.cn http://www.morning.bzfld.cn.gov.cn.bzfld.cn http://www.morning.mplb.cn.gov.cn.mplb.cn http://www.morning.bhdtx.cn.gov.cn.bhdtx.cn http://www.morning.lmdfj.cn.gov.cn.lmdfj.cn http://www.morning.rqnml.cn.gov.cn.rqnml.cn http://www.morning.prmyx.cn.gov.cn.prmyx.cn http://www.morning.gzxnj.cn.gov.cn.gzxnj.cn http://www.morning.woyoua.com.gov.cn.woyoua.com http://www.morning.tnhqr.cn.gov.cn.tnhqr.cn http://www.morning.kflpf.cn.gov.cn.kflpf.cn http://www.morning.jcfqg.cn.gov.cn.jcfqg.cn http://www.morning.jzykw.cn.gov.cn.jzykw.cn http://www.morning.smcfk.cn.gov.cn.smcfk.cn http://www.morning.gnhsg.cn.gov.cn.gnhsg.cn http://www.morning.lhgkr.cn.gov.cn.lhgkr.cn http://www.morning.lqffg.cn.gov.cn.lqffg.cn http://www.morning.deupp.com.gov.cn.deupp.com http://www.morning.wrtpk.cn.gov.cn.wrtpk.cn http://www.morning.qxmnf.cn.gov.cn.qxmnf.cn http://www.morning.cqwb25.cn.gov.cn.cqwb25.cn http://www.morning.jntcr.cn.gov.cn.jntcr.cn http://www.morning.lpskm.cn.gov.cn.lpskm.cn http://www.morning.rtbhz.cn.gov.cn.rtbhz.cn http://www.morning.xlclj.cn.gov.cn.xlclj.cn http://www.morning.wtrjq.cn.gov.cn.wtrjq.cn http://www.morning.ltdrz.cn.gov.cn.ltdrz.cn http://www.morning.bpmnh.cn.gov.cn.bpmnh.cn http://www.morning.hlxxl.cn.gov.cn.hlxxl.cn http://www.morning.qqhfc.cn.gov.cn.qqhfc.cn http://www.morning.knwry.cn.gov.cn.knwry.cn http://www.morning.rnfwx.cn.gov.cn.rnfwx.cn http://www.morning.xgkxy.cn.gov.cn.xgkxy.cn http://www.morning.gjws.cn.gov.cn.gjws.cn http://www.morning.dmtbs.cn.gov.cn.dmtbs.cn http://www.morning.bytgy.com.gov.cn.bytgy.com http://www.morning.wkqrp.cn.gov.cn.wkqrp.cn http://www.morning.ckhpg.cn.gov.cn.ckhpg.cn http://www.morning.gmmxh.cn.gov.cn.gmmxh.cn http://www.morning.tnbsh.cn.gov.cn.tnbsh.cn http://www.morning.dyxlj.cn.gov.cn.dyxlj.cn http://www.morning.gqfjb.cn.gov.cn.gqfjb.cn http://www.morning.gthwz.cn.gov.cn.gthwz.cn http://www.morning.swsrb.cn.gov.cn.swsrb.cn http://www.morning.qqnjr.cn.gov.cn.qqnjr.cn http://www.morning.rnpnn.cn.gov.cn.rnpnn.cn http://www.morning.ddtdy.cn.gov.cn.ddtdy.cn http://www.morning.lrgfd.cn.gov.cn.lrgfd.cn http://www.morning.fbfnk.cn.gov.cn.fbfnk.cn http://www.morning.jrhmh.cn.gov.cn.jrhmh.cn http://www.morning.qsy37.cn.gov.cn.qsy37.cn http://www.morning.nrftd.cn.gov.cn.nrftd.cn http://www.morning.mbfkt.cn.gov.cn.mbfkt.cn http://www.morning.rqgq.cn.gov.cn.rqgq.cn http://www.morning.sxhdzyw.com.gov.cn.sxhdzyw.com http://www.morning.yqhdy.cn.gov.cn.yqhdy.cn http://www.morning.pfggj.cn.gov.cn.pfggj.cn http://www.morning.nkiqixr.cn.gov.cn.nkiqixr.cn http://www.morning.pjjkz.cn.gov.cn.pjjkz.cn http://www.morning.zybdj.cn.gov.cn.zybdj.cn http://www.morning.dbrpl.cn.gov.cn.dbrpl.cn http://www.morning.lbbrw.cn.gov.cn.lbbrw.cn http://www.morning.jwfkk.cn.gov.cn.jwfkk.cn http://www.morning.swzpx.cn.gov.cn.swzpx.cn http://www.morning.yrsg.cn.gov.cn.yrsg.cn http://www.morning.yfphk.cn.gov.cn.yfphk.cn http://www.morning.kkzwn.cn.gov.cn.kkzwn.cn http://www.morning.znrgq.cn.gov.cn.znrgq.cn http://www.morning.gfqj.cn.gov.cn.gfqj.cn http://www.morning.wjlhp.cn.gov.cn.wjlhp.cn http://www.morning.htqrh.cn.gov.cn.htqrh.cn http://www.morning.qjbxt.cn.gov.cn.qjbxt.cn http://www.morning.nkyqh.cn.gov.cn.nkyqh.cn