如何在 Activiti 5.22.0 中设置作业截止日期?



我得到了对 Job 对象的引用,如下所示:

Job timer = managementService.createJobQuery().processInstanceId(execution.getParentId()).singleResult();

谁能告诉我如何将计时器截止日期设置为任意 Activiti 5.22.0 中的日期或时间段?

我在管理服务或作业类中找不到合适的方法。

此致敬意。

对我来说,我只找到了一种方法:
创建一个新的计时器并从旧计时器设置配置。
这是我如何做到这一点的一个片段示例,不要忘记修复它,以避免 NPE

TimerEntity oldTimer = (TimerEntity) managementService.createJobQuery()
.processInstanceId("YOUR_PROCESS_INSTANCE_ID")
.timers()
.singleResult();
commandExecutor.execute(new Command<Void>() {
@Override
public Void execute(CommandContext commandContext) {
oldTimer.delete();
TimerEntity newTimer = new TimerEntity();
newTimer.setJobHandlerConfiguration(oldTimer.getJobHandlerConfiguration());
newTimer.setJobHandlerType(oldTimer.getJobHandlerType());
newTimer.setExclusive(oldTimer.isExclusive());
newTimer.setRepeat(oldTimer.getRepeat());
newTimer.setRetries(oldTimer.getRetries());
newTimer.setEndDate(oldTimer.getEndDate());
newTimer.setExecutionId(oldTimer.getExecutionId());
newTimer.setProcessInstanceId(oldTimer.getProcessInstanceId());
newTimer.setProcessDefinitionId(oldTimer.getProcessDefinitionId());
newTimer.setTenantId(oldTimer.getTenantId());
// Sets a new date
newTimer.setDuedate(new Date());
commandContext.getJobEntityManager().schedule(newTimer);
return null;
}
});

最新更新