TLog icon indicating copy to clipboard operation
TLog copied to clipboard

xxl-job集成,多个job任务或单个任务多次请求 traceId一直一样

Open Pozz-Li opened this issue 4 years ago • 2 comments

不同job任务使用了同一个traceId,同一个任务多次执行也使用了同一个traceId。可查看附件 image

new 5.txt

Pozz-Li avatar Oct 26 '21 11:10 Pozz-Li

使用的tlog版本是1.3.3

Pozz-Li avatar Oct 26 '21 11:10 Pozz-Li

使用的tlog版本是1.3.3

因为xxl-job使用线程池调度,所以会有重复问题。我的解决方案是用spring切面处理。

@Component
@Aspect
public class TLogXxlJobHandlerAspect {
    private TLogRPCHandler tLogRPCHandler = new TLogRPCHandler();
 
    @Pointcut("@annotation(com.xxl.job.core.handler.annotation.XxlJob)")
    public void xxlJobHandlerAspect() {}
 
    @Before("xxlJobHandlerAspect()")
    public void doBefore() {
        tLogRPCHandler.processProviderSide(new TLogLabelBean());
    }
 
    @After("xxlJobHandlerAspect()")
    public void doAfter() {
        tLogRPCHandler.cleanThreadLocal();
    }
}

wydpp avatar Nov 15 '21 08:11 wydpp