opt: 线程池线程复用导致链路id相同

This commit is contained in:
2024-07-15 15:40:27 +08:00
parent 3e3a129372
commit f085095da5

View File

@@ -1,12 +1,13 @@
package org.nl.system.service.quartz.utils; package org.nl.system.service.quartz.utils;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.yomahub.tlog.core.thread.TLogInheritableTask;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.nl.modules.wql.util.SpringContextHolder; import org.nl.modules.wql.util.SpringContextHolder;
import org.springframework.util.ReflectionUtils; import org.springframework.util.ReflectionUtils;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.concurrent.Callable;
/** /**
* 执行定时任务 * 执行定时任务
@@ -14,7 +15,7 @@ import java.util.concurrent.Callable;
* @author / * @author /
*/ */
@Slf4j @Slf4j
public class QuartzRunnable implements Callable { public class QuartzRunnable extends TLogInheritableTask {
private final Object target; private final Object target;
private final Method method; private final Method method;
@@ -32,14 +33,15 @@ public class QuartzRunnable implements Callable {
} }
} }
@SneakyThrows
@Override @Override
public Object call() throws Exception { public void runTask() {
ReflectionUtils.makeAccessible(method); ReflectionUtils.makeAccessible(method);
if (StrUtil.isNotEmpty(params)) { if (StrUtil.isNotEmpty(params)) {
method.invoke(target, params); method.invoke(target, params);
} else { } else {
method.invoke(target); method.invoke(target);
} }
return null;
} }
} }