Skip to content
New issue

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

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

Open
Pozz-Li opened this issue Oct 26, 2021 · 2 comments

Comments

@Pozz-Li
Copy link

Pozz-Li commented Oct 26, 2021

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

new 5.txt

@Pozz-Li
Copy link
Author

Pozz-Li commented Oct 26, 2021

使用的tlog版本是1.3.3

@wydpp
Copy link

wydpp commented Nov 15, 2021

使用的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();
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants