[xuxueli/xxl-job]Case Study:调度任务可以正常执行,回调抛出异常

2024-05-15 471 views
3

执行器正常,就是回调给调度中心的时候抛出异常,导致任务一直无法被终止, 请问这是什么原因导致的?我是在docker容器里面跑的

如下图所示

wx20180416-195133 wx20180416-195145

wx20180416-194942

task-scheduling_1  | 2018-04-16 19:40:06 xxl-job-admin [com.xxl.job.admin.core.thread.JobFailMonitorHelper]-[Thread-8]-[run]-[60]-[INFO] >>>>>>>>>>> job monitor, job running, JobLogId:95
task-scheduling_1  | 2018-04-16 19:40:10 xxl-job-executor-sample-spring [com.xxl.job.core.thread.TriggerCallbackThread]-[Thread-15]-[doCallback]-[118]-[ERROR] >>>>>>>>>>> xxl-job callback error, callbackParamList:[HandleCallbackParam{logId=95, executeResult=ReturnT [code=200, msg=null, content=null]}]
task-scheduling_1  | java.lang.RuntimeException: RpcResponse byte[] is null
task-scheduling_1  |    at com.xxl.job.core.rpc.netcom.NetComClientProxy$1.invoke(NetComClientProxy.java:65)
task-scheduling_1  |    at com.sun.proxy.$Proxy35.callback(Unknown Source)
task-scheduling_1  |    at com.xxl.job.core.thread.TriggerCallbackThread.doCallback(TriggerCallbackThread.java:109)
task-scheduling_1  |    at com.xxl.job.core.thread.TriggerCallbackThread.access$200(TriggerCallbackThread.java:17)
task-scheduling_1  |    at com.xxl.job.core.thread.TriggerCallbackThread$1.run(TriggerCallbackThread.java:65)
task-scheduling_1  |    at java.lang.Thread.run(Thread.java:748)
task-scheduling_1  | 2018-04-16 19:40:16 xxl-job-executor-sample-spring [com.xxl.job.core.thread.ExecutorRegistryThread]-[Thread-14]-[run]-[66]-[INFO] >>>>>>>>>>> xxl-job registry error, registryParam:RegistryParam{registGroup='EXECUTOR', registryKey='xxl-job-executor-sample', registryValue='0.0.0.0:9999'}
task-scheduling_1  | java.lang.RuntimeException: RpcResponse byte[] is null
task-scheduling_1  |    at com.xxl.job.core.rpc.netcom.NetComClientProxy$1.invoke(NetComClientProxy.java:65)
task-scheduling_1  |    at com.sun.proxy.$Proxy35.registry(Unknown Source)
task-scheduling_1  |    at com.xxl.job.core.thread.ExecutorRegistryThread$1.run(ExecutorRegistryThread.java:57)
task-scheduling_1  |    at java.lang.Thread.run(Thread.java:748)
task-scheduling_1  | 2018-04-16 19:40:16 xxl-job-admin [com.xxl.job.admin.core.thread.JobFailMonitorHelper]-[Thread-8]-[run]-[60]-[INFO] >>>>>>>>>>> job monitor, job running, JobLogId:95

回答

5

你好,任务回调失败的原因可能有以下几个方面引起: 1、调度中心未启动:无法提供回调API服务; 2、网络问题:调度中心与执行器跨机器部署时,网络问题导致执行器无法ping通调度中心; 3、回调地址配置错误:导致回调请求发送失败; 可以逐个确认排查。

4

@xuxueli 已解决, 确实是回调地址配置问题, 谢谢

4

遇到同样问题 希望给后来的童鞋一些提示 现在代码版本中执行器默认回调地址是 http://192.168.xxx.xxx:8080/xxl-job-admin 而默认的服务是没有 xxl-job-admin这个名称的

3

@timewind Thanks~ 找了半天,结果是这一个原因哈。

你好,任务回调失败的原因可能有以下几个方面引起: 1、调度中心未启动:无法提供回调API服务; 2、网络问题:调度中心与执行器跨机器部署时,网络问题导致执行器无法ping通调度中心; 3、回调地址配置错误:导致回调请求发送失败;

默认回调地址是 http://192.168.xxx.xxx:8080/xxl-job-admin 而默认的服务是没有 xxl-job-admin这个名称的。 qq 20180815171924

5

触发调度: address:http://127.0.0.1:8080 code:500 msg:java.lang.RuntimeException: Client-error:unknown code for readObject at 0x3c (<)

1

您好,在使用xxljob过程呢个中任务回调失败,日志报空指针异常,但是本地控制台不报错 图片, 防火墙全部都已关闭,同事电脑调用没问题,貌似只有我的出现了这个情况,无法找到具体原因,希望回复一下提供一下思路,配置应该是没任何问题的,调度室idea无任何报错 图片

3

回调的执行,好像有子任务ID 才可以进行,对于 一个正常的任务如果需要回调,又该如何回调?
版本v2.0.2 源代码

private ReturnT<String> callback(HandleCallbackParam handleCallbackParam) {
        // valid log item
        XxlJobLog log = xxlJobLogDao.load(handleCallbackParam.getLogId());
        if (log == null) {
            return new ReturnT<String>(ReturnT.FAIL_CODE, "log item not found.");
        }
        if (log.getHandleCode() > 0) {
            return new ReturnT<String>(ReturnT.FAIL_CODE, "log repeate callback.");     // avoid repeat callback, trigger child job etc
        }

        // trigger success, to trigger child job
        String callbackMsg = null;
        if (IJobHandler.SUCCESS.getCode() == handleCallbackParam.getExecuteResult().getCode()) {
            XxlJobInfo xxlJobInfo = xxlJobInfoDao.loadById(log.getJobId());
            if (xxlJobInfo!=null && xxlJobInfo.getChildJobId()!=null && xxlJobInfo.getChildJobId().trim().length()>0) {
                callbackMsg = "<br><br><span style=\"color:#00c0ef;\" > >>>>>>>>>>>"+ I18nUtil.getString("jobconf_trigger_child_run") +"<<<<<<<<<<< </span><br>";

                String[] childJobIds = xxlJobInfo.getChildJobId().split(",");
                for (int i = 0; i < childJobIds.length; i++) {
                    int childJobId = (childJobIds[i]!=null && childJobIds[i].trim().length()>0 && isNumeric(childJobIds[i]))?Integer.valueOf(childJobIds[i]):-1;
                    if (childJobId > 0) {

                        JobTriggerPoolHelper.trigger(childJobId, TriggerTypeEnum.PARENT, -1, null, null);
                        ReturnT<String> triggerChildResult = ReturnT.SUCCESS;

                        // add msg
                        callbackMsg += MessageFormat.format(I18nUtil.getString("jobconf_callback_child_msg1"),
                                (i+1),
                                childJobIds.length,
                                childJobIds[i],
                                (triggerChildResult.getCode()==ReturnT.SUCCESS_CODE?I18nUtil.getString("system_success"):I18nUtil.getString("system_fail")),
                                triggerChildResult.getMsg());
                    } else {
                        callbackMsg += MessageFormat.format(I18nUtil.getString("jobconf_callback_child_msg2"),
                                (i+1),
                                childJobIds.length,
                                childJobIds[i]);
                    }
                }

            }
        }

        // handle msg
        StringBuffer handleMsg = new StringBuffer();
        if (log.getHandleMsg()!=null) {
            handleMsg.append(log.getHandleMsg()).append("<br>");
        }
        if (handleCallbackParam.getExecuteResult().getMsg() != null) {
            handleMsg.append(handleCallbackParam.getExecuteResult().getMsg());
        }
        if (callbackMsg != null) {
            handleMsg.append(callbackMsg);
        }

        // success, save log
        log.setHandleTime(new Date());
        log.setHandleCode(handleCallbackParam.getExecuteResult().getCode());
        log.setHandleMsg(handleMsg.toString());
        xxlJobLogDao.updateHandleInfo(log);

        return ReturnT.SUCCESS;
    }
4

请问能否自定义回调方法?

4

你好 我这边启动的时候执行器就失败了 我的配置是 `### 调度中心部署跟地址 [选填]:如调度中心集群部署存在多个地址则用逗号分隔。执行器将会使用该地址进行"执行器心跳注册"和"任务结果回调";为空则关闭自动注册; xxl.job.admin.addresses=http://127.0.0.1:8080

执行器通讯TOKEN [选填]:非空时启用;

xxl.job.accessToken=

执行器AppName [选填]:执行器心跳注册分组依据;为空则关闭自动注册

xxl.job.executor.appname=xxl-job-executor

执行器注册 [选填]:优先使用该配置作为注册地址,为空时使用内嵌服务 ”IP:PORT“ 作为注册地址。从而更灵活的支持容器类型执行器动态IP和动态映射端口问题。

xxl.job.executor.address=

执行器IP [选填]:默认为空表示自动获取IP,多网卡时可手动设置指定IP,该IP不会绑定Host仅作为通讯的时候用;地址信息用于 "执行器注册" 和 "调度中心请求并触发任务";

xxl.job.executor.ip= 127.0.0.1

执行器端口号 [选填]:小于等于0则自动获取;默认端口为9999,单机部署多个执行器时,注意要配置不同执行器端口;

xxl.job.executor.port=9999

执行器运行日志文件存储磁盘路径 [选填] :需要对该路径拥有读写权限;为空则使用默认路径;

xxl.job.executor.logpath=./logs/xxl-job/jobhandler

执行器日志文件保存天数 [选填] : 过期日志自动清理, 限制值大于等于3时生效; 否则, 如-1, 关闭自动清理功能;

xxl.job.executor.logretentiondays=30 这样的有啥问题吗 哪里配置的不对 启动就报错2021-01-09 09:30:31.520 [xxl-job, executor ExecutorRegistryThread] INFO com.xxl.job.core.thread.ExecutorRegistryThread->>>>>>>>>>> xxl-job registry fail, registryParam:RegistryParam{registryGroup='EXECUTOR', registryKey='xxl-job-executor', registryValue='http://127.0.0.1:9999/'}, registryResult:ReturnT [code=4015, msg=鏈櫥褰?, content=null] `