执行器集成XxlJob需要一下几个步骤
1、版本确认。
2、Bean的执行器配置
3、继承 IJobHandler
一、确认版本
首先确认XxlJob与调度平台的版本是否一致,版本不一致会导致注册问题。
二、 Bean的执行器配置
使用Bean的模式,需要一个Handler,及配置一个执行器(XxlJobExecutor)
@Bean(initMethod = "start", destroyMethod = "destroy") public XxlJobExecutor xxlJobExecutor() { if (!executorAble){ logger.debug("current executor can`t able..."); return null; } logger.info(">>>>>>>>>>> xxl-job config init."); XxlJobExecutor xxlJobExecutor = new XxlJobExecutor(); xxlJobExecutor.setIp(ip); xxlJobExecutor.setPort(port); xxlJobExecutor.setAppName(appname); xxlJobExecutor.setAdminAddresses(adminAddresses); xxlJobExecutor.setLogPath(logPath); xxlJobExecutor.setAccessToken(accessToken); return xxlJobExecutor; }
其中:ip,port,appname,adminAddress