Skip to content

触发重试机制时,RpcContext中attachment传递不正确的问题 #513

@aguang0608

Description

@aguang0608

您好,我尝试通过自定义Filter的方式在Consumer和Provider两侧传递一些信息,具体逻辑如下:

ConsumerFilter:

    ...
    UUID traceId = UUID.randomUUID();
    logger.info("traceId = {}", traceId);
    RpcContext.setAttachment("traceId", traceId.toString());
    return invoker.invoke(invocation);
    ...

ProviderFilter:

    ...
    UUID traceId = UUID.fromString(RpcContext.getAttachment("traceId"));
    logger.info("traceId = {}", traceId);
    invoker.invoke(invocation);
    ...

实验过程中,由于Provider端invoke的代码处理较慢,触发了Dubbo的超时重试机制,在一次接口调用中,ConsumerFilter和ProviderFilter的逻辑分别触发了两次;显然,两次实际传递的traceId是不同的,但是在ProviderFilter端,两次收到的traceId是一样的(都是第一次传递过去的值);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions