We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在云原生时代,随着容器化和弹性扩缩容的需求日益增长,我们发现当前 XxlJobExecutor 的 destroy() 方法在停止任务时可能会中断正在执行的任务线程,这可能会导致任务执行不完整(对于比较复杂的定时任务时,未加事物保证)或结果未能正确上报到 xxl-job admin。为了更好地适应云原生环境,我们建议在 XxlJobExecutor 中增加一个 elegantDestroy() 方法,实现优雅停机。 具体建议: 新增 elegantDestroy() 方法: 在 XxlJobExecutor 类中新增一个 elegantDestroy() 方法,该方法会在停止任务前等待所有正在执行的任务线程完成,并确保任务执行结果已成功上报到 xxl-job admin。 现有 destroy() 方法: 现有的 destroy() 方法可以保持不变,继续用于快速关闭场景。同时,在文档中明确区分 destroy() 和 elegantDestroy() 的使用场景,帮助用户根据实际需求选择合适的方法。 具体实现思路: 在 elegantDestroy() 方法中,首先遍历 jobThreadRepository 中的所有任务线程,标记这些线程为“待停止”状态。 对于每个标记为“待停止”的线程,等待其执行完毕并确保执行结果已上报到 xxl-job admin。 一旦所有任务线程都已完成,再执行清理操作(如关闭日志清理线程、触发回调线程等)。 具体实现方式: 确认下是否将oldJobThread.interrupt();注释掉,即可实现等待所有的任务线程执行结束,即可实现缩容场景的优雅停机?
public static JobThread removeJobThread(int jobId, String removeOldReason){ JobThread oldJobThread = jobThreadRepository.remove(jobId); if (oldJobThread != null) { oldJobThread.toStop(removeOldReason); //oldJobThread.interrupt(); return oldJobThread; } return null; }
阿里云xxljob优雅下线文档:https://help.aliyun.com/zh/schedulerx/schedulerx-xxljob/use-cases/how-to-enable-graceful-shutdown
The text was updated successfully, but these errors were encountered:
No branches or pull requests
在云原生时代,随着容器化和弹性扩缩容的需求日益增长,我们发现当前 XxlJobExecutor 的 destroy() 方法在停止任务时可能会中断正在执行的任务线程,这可能会导致任务执行不完整(对于比较复杂的定时任务时,未加事物保证)或结果未能正确上报到 xxl-job admin。为了更好地适应云原生环境,我们建议在 XxlJobExecutor 中增加一个 elegantDestroy() 方法,实现优雅停机。
具体建议:
新增 elegantDestroy() 方法:
在 XxlJobExecutor 类中新增一个 elegantDestroy() 方法,该方法会在停止任务前等待所有正在执行的任务线程完成,并确保任务执行结果已成功上报到 xxl-job admin。
现有 destroy() 方法:
现有的 destroy() 方法可以保持不变,继续用于快速关闭场景。同时,在文档中明确区分 destroy() 和 elegantDestroy() 的使用场景,帮助用户根据实际需求选择合适的方法。
具体实现思路:
在 elegantDestroy() 方法中,首先遍历 jobThreadRepository 中的所有任务线程,标记这些线程为“待停止”状态。
对于每个标记为“待停止”的线程,等待其执行完毕并确保执行结果已上报到 xxl-job admin。
一旦所有任务线程都已完成,再执行清理操作(如关闭日志清理线程、触发回调线程等)。
具体实现方式:
确认下是否将oldJobThread.interrupt();注释掉,即可实现等待所有的任务线程执行结束,即可实现缩容场景的优雅停机?
阿里云xxljob优雅下线文档:https://help.aliyun.com/zh/schedulerx/schedulerx-xxljob/use-cases/how-to-enable-graceful-shutdown
The text was updated successfully, but these errors were encountered: