wxbty opened a new issue, #11657:
URL: https://github.com/apache/dubbo/issues/11657

   ### Environment
   
   * Dubbo version: 3.2.0-beta.6-SNAPSHOT
   * Operating System version: mac m1
   * Java version: 1.8
   
   ### Steps to reproduce this issue
   
   1. Create provider and consumer projects, as follows:
      provider:
   
   ```xml
      <properties>
           <dubbo.version>3.2.0-beta.6-SNAPSHOT</dubbo.version>
       </properties>
   ```
   
   ```yaml
   dubbo:
     application:
       name: sp-provider
     registry:
       address: zookeeper://127.0.0.1:2181
     protocol:
       port: 20881
   ```
   
      ```java
      @DubboService
      public class GameServiceImpl implements GameService {
          public String play(String name) {
            RpcContext.getServerContext().setAttachment("env","zhejiang");
            return "hello 2181:"+name;
          }
      }
      ```
   
      consumer:
   
      ```xml
      <properties>
           <dubbo.version>3.2.0-beta.6-SNAPSHOT</dubbo.version>
       </properties>
      ```
   
   ```yaml
   dubbo:
     application:
       name: sp-consumer
     registry:
       address: zookeeper://127.0.0.1:2181
   ```
   
   ```java
   @DubboReference
   private GameService gameService;
   
   
    public static void main(String[] args) {
           ConfigurableApplicationContext context = 
SpringApplication.run(ConsumerApplication.class, args);
           ConsumerApplication bean =  (ConsumerApplication) 
context.getBean("consumerApplication");
           System.out.println(bean.play());
       }
   
       public String play() {
           return gameService.play("feiguohai");
       }
   ```
   
   ```java
   @Activate(group = {CONSUMER}, order = -1)
   public class MetricsFilter implements Filter, BaseFilter.Listener {
   
       @Override
       public Result invoke(Invoker<?> invoker, Invocation invocation) throws 
RpcException {
   
           return invoker.invoke(invocation);
   
       }
   
       @Override
       public void onResponse(Result result, Invoker<?> invoker, Invocation 
invocation) {
           Object env = RpcContext.getServerContext().getAttachment("env");
           System.out.println("env=" + env);
       }
   
       @Override
       public void onError(Throwable t, Invoker<?> invoker, Invocation 
invocation) {
   
       }
   
   }
   ```
   
   2. run main func
   
   
   
   ### Expected Behavior
   
   MetricsFilter sout  env=zhejiang
   
   ### Actual Behavior
   
   MetricsFilter sout  env=null


-- 
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