分布式调度平台启动报错:com.xxl.rpc.util.XxlRpcException: xxl-rpc request data empty.

一 问题:

分布式调度平台XXL-JOB启动时报以下错误:com.xxl.rpc.util.XxlRpcException: xxl-rpc request data empty.

我自己项目中的相关配置为:
maven依赖为:

        
            com.xuxueli
            xxl-job-core
            2.1.2
        

application.yml配置为:

xxl:
  job:
    executor:
      appname: xxl-job-demo
      #ip: 10.123.1.53
      port: 10358
      logpath: ./logs/xxl-job/jobhandler
      logretentiondays: -1
    admin:
      addresses: http://10.24.24.19:8489/xxl-job-admin
    accessToken:
XxlJobConfig配置类代码为:
@Configuration
@ComponentScan(basePackages = "com.zq.xxljobdemo.job")
@Slf4j
public class XxlJobConfig {

    @Value("${xxl.job.admin.addresses}")
    private String adminAddresses;

    @Value("${xxl.job.executor.appname}")
    private String appName;

    /*@Value("${xxl.job.executor.ip}")
    private String ip;*/

    @Value("${xxl.job.executor.port}")
    private int port;

    @Value("${xxl.job.accessToken}")
    private String accessToken;

    @Value("${xxl.job.executor.logpath}")
    private String logPath;

    @Value("${xxl.job.executor.logretentiondays}")
    private int logRetentionDays;


    @Bean(initMethod = "start", destroyMethod = "destroy")
    public XxlJobSpringExecutor xxlJobExecutor() {
        log.info(">>>>>>>>>>> xxl-job config init.");
        XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
        xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
        xxlJobSpringExecutor.setAppName(appName);
        //xxlJobSpringExecutor.setIp(ip);
        xxlJobSpringExecutor.setPort(port);
        xxlJobSpringExecutor.setAccessToken(accessToken);
        xxlJobSpringExecutor.setLogPath(logPath);
        xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);

        return xxlJobSpringExecutor;
    }

}

Job任务代码:

@Slf4j
@Component
@JobHandler(value = "demoJobHandler")
@Configuration
public class DemoJobHandler extends IJobHandler {
    @Override
    public ReturnT testJobHandler(String param) throws Exception {
        log.info("XXL-JOB, Hello World.{}" , param);
        return ReturnT.SUCCESS;
    }
}

以上配置,启动时会报题目中所列的错误。

经过查阅资料,xxl-job-core最新版本2.1.2中@JobHandler注解已过时,取而代之的是@XxlJob注解,也不需要去继承IJobHandler类。

将Job任务代码作如下修改:

@Slf4j
@Component
public class DemoJobHandler {

    @XxlJob("demoJobHandler")
    public ReturnT execute(String s) throws Exception {
        log.debug("XXL-JOB Hello World");
        return ReturnT.SUCCESS;
    }
}

重新启动,问题解决。

在XXL-JOB中添加配置:

第一步:添加执行器,执行器的AppName和配置文件中保持一致。

分布式调度平台启动报错:com.xxl.rpc.util.XxlRpcException: xxl-rpc request data empty._第1张图片

第二步 在任务管理中新建任务,JobHandler需要和代码中保持一致。

分布式调度平台启动报错:com.xxl.rpc.util.XxlRpcException: xxl-rpc request data empty._第2张图片

 

分布式调度平台启动报错:com.xxl.rpc.util.XxlRpcException: xxl-rpc request data empty._第3张图片

配置完后,启动定时任务,查看日志。

分布式调度平台启动报错:com.xxl.rpc.util.XxlRpcException: xxl-rpc request data empty._第4张图片

你可能感兴趣的:(SpringBoot)