支持执行器通过XxlJobHelper或XxlJobContext获取job的触发时间戳 #3840
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce? (check at least one)
The description of the PR:
【背景】通过xxljob的分片广播特性加速生成数据,在某些业务场景下,仅靠计算分片信息(shardIndex和shardTotal)可能会容易产生分片数据倾斜(即一些分片实例很快执行完,而另一些却执行很慢)。比如业务方有一个t_task表,里面记录了一个个待执行的任务,但每一个t_task.id背后所需要执行的时间差异很大且不好预估(这取决于每个t_task.id背后各自所需的数据量)。
【思路】分片执行时,不依赖于shardIndex和shardTotal,而是改为使用一个带”执行版本”的乐观锁机制,且这个”执行版本“应该由xxljob-admin统一提供给各个执行器分片使用,每个分片实例都扫描每一个t_task记录,并以乐观锁的”抢占式+一次性“特性来执行。而这个统一的”执行版本“,最直观的一种实现方式就是使用由xxljob-admin触发作业时的时间戳(即:com.xxl.job.core.openapi.model.TriggerRequest#logDateTime)
【问题】当前最新版本的xxljob(2025.11.04的master分支),在com.xxl.job.core.context.XxlJobHelper和com.xxl.job.core.context.XxlJobContext中都没有提供获取触发该作业的时间戳。
本PR正是希望实现执行器获取job的触发时间戳的功能,请帮忙review一下代码,谢谢。
Other information:
相关Issue:Issue-3481