bykgh commented on issue #9267:
URL: https://github.com/apache/dubbo/issues/9267#issuecomment-968548747


   > 确认一下providerTraceFilter 所在的类二进制文件是否有被打进去
   
   打进去了, 这个providerTraceFilter,和 
META-INF/dubbo/internal/org.apache.dubbo.rpc.filter 文件我是打在一个jar包中,给另外一个spring 
boot 的jar项目引用的。
   
   这是providerTraceFilter:
   
   `@Activate(group = {CONSUMER, PROVIDER}, value = VALIDATION_KEY, order = 
10000)
   public class ProviderTraceFilter  extends ValidationFilter {
        private Logger logger  = LoggerFactory.getLogger(this.getClass());
   
        // 调用过程拦截
        @Override
        public Result invoke(Invoker<?> invoker, Invocation invocation) throws 
RpcException {
                try {
                        //获取session信息
                        initSession(invocation);
                        return invoker.invoke(invocation);
                }catch (RpcException e) {
                        throw e;
                }finally {
                }
        }
        private void initSession(Invocation invocation) {
                String sessionId = invocation.getAttachment("sessionId");
                String qrCode = invocation.getAttachment("qrCode");
                String openId = invocation.getAttachment("openId");
                if (null != sessionId) {
                        MDC.put("sessionId",sessionId);
                }
                if (null != qrCode){
                        MDC.put("qrCode", qrCode);
                }
                if (null != openId){
                        MDC.put("openId", openId);
                }
        }
   }`
   
   pom.xml
   `    <dependencies>
           <dependency>
               <groupId>org.springframework.boot</groupId>
               <artifactId>spring-boot-starter-web</artifactId>
           </dependency>
           <dependency>
               <groupId>org.apache.httpcomponents</groupId>
               <artifactId>httpcore</artifactId>
           </dependency>
           <dependency>
               <groupId>org.apache.httpcomponents</groupId>
               <artifactId>httpclient</artifactId>
           </dependency>
       </dependencies>
   
       <build>
           <plugins>
               <plugin>
                   <groupId>org.apache.maven.plugins</groupId>
                   <artifactId>maven-compiler-plugin</artifactId>
                   <configuration>
                       <source>${java.version}</source>
                       <target>${java.version}</target>
                       <encoding>UTF-8</encoding>
                   </configuration>
               </plugin>
               <plugin>
                   <groupId>org.springframework.boot</groupId>
                   <artifactId>spring-boot-maven-plugin</artifactId>
                   <configuration>
                       <skip>true</skip>
                   </configuration>
               </plugin>
           </plugins>
           <resources>
               <resource>
                   <directory>${basedir}/src/main/resources</directory>
                   <includes>
                       <include>**/*.filter</include>
                   </includes>
               </resource>
           </resources>
       </build>`
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to