You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/09/09 07:02:05 UTC

[GitHub] [dubbo] EarthChen opened a new issue #8738: [3.0-Triple] Attachment is lost when calling with registry (like zk)

EarthChen opened a new issue #8738:
URL: https://github.com/apache/dubbo/issues/8738


   - [ ] I have searched the [issues](https://github.com/apache/dubbo/issues) of this repository and believe that this is not a duplicate.
   - [ ] I have checked the [FAQ](https://github.com/apache/dubbo/blob/master/FAQ.md) of this repository and believe that this is not a duplicate.
   
   ### Environment
   
   * Dubbo version: 3.0.3-SNAPSHOT
   * Operating System version: macos
   * Java version: 1.8
   
   ### Steps to reproduce this issue
   
   #### code
   
   1. server
   ```java
    @Override
       public GreeterReply greetWithAttachment(GreeterRequest request) {
           final String key = "user-attachment";
           final String value = RpcContext.getServerAttachment().getAttachment(key);
           RpcContext.getServerContext().setObjectAttachment(key, value);
           return GreeterReply.newBuilder().setMessage("hello," + request.getName()).build();
       }
   ```
   
   2. client
   ```java
    @Test
       public void attachmentTest() {
           final String key = "user-attachment";
           final String value = "attachment-value";
           RpcContext.removeClientAttachment();
           RpcContext.getClientAttachment().setAttachment(key, value);
           delegate.greetWithAttachment(GreeterRequest.newBuilder().setName("meta").build());
           final String returned = (String) RpcContext.getServiceContext().getObjectAttachment(key);
           Assert.assertEquals(value, returned);
       }
   ```
   
   #### steps
   
   1. start provider
   2. start consumer with Url directly connect
   3. start consumer with zk registry
   
   Pls. provide [GitHub address] to reproduce this issue.
   
   https://github.com/apache/dubbo-samples/pull/356
   
   ### Expected Result
   
   consumer test is ok
   
   ### Actual Result
   
   The consumer test using the URL direct connection succeeded.
   
   The consumer test using Zookeper failed.
   
   
   If there is an exception, please attach the exception trace:
   
   ```
   Just put your stack trace here!
   ```
   


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] fengcunhan edited a comment on issue #8738: [3.0] Attachment is lost when calling without registry

Posted by GitBox <gi...@apache.org>.
fengcunhan edited a comment on issue #8738:
URL: https://github.com/apache/dubbo/issues/8738#issuecomment-916780084


   你使用错了API,如果要获取服务器端带来的参数,应该使用RpcContext.getServerContext()
   
   ` public void attachmentTest() {
           final String key = "user-attachment";
           final String value = "attachment-value";
           RpcContext.removeClientAttachment();
           RpcContext.getClientAttachment().setAttachment(key, value);
           delegate.greetWithAttachment(GreeterRequest.newBuilder().setName("meta").build());
           final String returned = (String) RpcContext.**getServerContext**().getObjectAttachment(key);
           Assert.assertEquals(value, returned);
       } `


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] icankeep commented on issue #8738: [3.0-Triple] Attachment is lost when calling with registry (like zk)

Posted by GitBox <gi...@apache.org>.
icankeep commented on issue #8738:
URL: https://github.com/apache/dubbo/issues/8738#issuecomment-916560942


   ![image](https://user-images.githubusercontent.com/39434627/132783707-45ba27b1-0c93-4025-9438-bd60dc4bb7d0.png)
   
   
   @AlbumenJ  这两段代码有些矛盾,3.0将RpcContext分成ServerContext、ServerAttachment、ClientAttachment、ServiceContext,有点不太清楚他们分别的应用场景,ServerAttachment和ServerContext的差异是?ServiceContext的定位是?看代码注解没太看明白,大佬有空帮忙解答下


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] fengcunhan commented on issue #8738: [3.0] Attachment is lost when calling without registry

Posted by GitBox <gi...@apache.org>.
fengcunhan commented on issue #8738:
URL: https://github.com/apache/dubbo/issues/8738#issuecomment-916788805


   如果要看Triple协议下的结果如何传递给client端的,client端如何解析,可以查看代码:
    org.apache.dubbo.rpc.protocol.tri.UnaryServerStream.invoke()方法,在方法里面会执行方法 final Result result = getInvoker().invoke(invocation); 调用,拿到结果以后,先传递CONTENT_TYPE,然后data,最后结束帧传递attachments。
   
   client解析部分可以看:org.apache.dubbo.rpc.protocol.tri.AbstractStream.AbstractTransportObserver.onMetadata()方法,这部分恰好对应上述服务器端传输部分
   


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] fengcunhan edited a comment on issue #8738: [3.0] Attachment is lost when calling without registry

Posted by GitBox <gi...@apache.org>.
fengcunhan edited a comment on issue #8738:
URL: https://github.com/apache/dubbo/issues/8738#issuecomment-916780084


   你使用错了API,如果要获取服务器端带来的参数,应该使用RpcContext.getServerContext()
   
   
   ` public void attachmentTest() {
           final String key = "user-attachment";
           final String value = "attachment-value";
           RpcContext.removeClientAttachment();
           RpcContext.getClientAttachment().setAttachment(key, value);
           delegate.greetWithAttachment(GreeterRequest.newBuilder().setName("meta").build());
           final String returned = (String) RpcContext.**getServerContext**().getObjectAttachment(key);
           Assert.assertEquals(value, returned);
       } `
   


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] EarthChen commented on issue #8738: [3.0-Triple] Attachment is lost when calling with registry (like zk)

Posted by GitBox <gi...@apache.org>.
EarthChen commented on issue #8738:
URL: https://github.com/apache/dubbo/issues/8738#issuecomment-916564344


   > ![image](https://user-images.githubusercontent.com/39434627/132783707-45ba27b1-0c93-4025-9438-bd60dc4bb7d0.png)
   > 
   > @AlbumenJ 这两段代码有些矛盾,finally已经将context清空了,onResponse再设置也没啥意义
   > 
   > 3.0将RpcContext分成ServerContext、ServerAttachment、ClientAttachment、ServiceContext,有点不太清楚他们分别的应用场景,ServerAttachment和ServerContext的差异是?ServiceContext的定位是?看代码注解没太看明白,大佬有空帮忙解答下
   
   可能是我的环境问题,后来的测试场景都是直连不能放入ServerContext
   
   原因是 filter 变为了 clusterfilter 而当使用 url 直连的时候 StaticDirectory会直接跳过 clusterfilter 的链的包装,如果只有一个 url ,都不会包装成 clusterinvoker
   


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] fengcunhan commented on issue #8738: [3.0] Attachment is lost when calling without registry

Posted by GitBox <gi...@apache.org>.
fengcunhan commented on issue #8738:
URL: https://github.com/apache/dubbo/issues/8738#issuecomment-916780084


   你使用错了API,如果要获取服务器端带来的参数,应该使用RpcContext.getServerContext()
   
   `public void attachmentTest() {
           final String key = "user-attachment";
           final String value = "attachment-value";
           RpcContext.removeClientAttachment();
           RpcContext.getClientAttachment().setAttachment(key, value);
           delegate.greetWithAttachment(GreeterRequest.newBuilder().setName("meta").build());
           final String returned = (String) RpcContext.**getServerContext**().getObjectAttachment(key);
           Assert.assertEquals(value, returned);
       }`


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] icankeep edited a comment on issue #8738: [3.0-Triple] Attachment is lost when calling with registry (like zk)

Posted by GitBox <gi...@apache.org>.
icankeep edited a comment on issue #8738:
URL: https://github.com/apache/dubbo/issues/8738#issuecomment-916560942


   ![image](https://user-images.githubusercontent.com/39434627/132783707-45ba27b1-0c93-4025-9438-bd60dc4bb7d0.png)
   
   
   @AlbumenJ  这两段代码有些矛盾,finally已经将context清空了,onResponse再设置也没啥意义
   
   3.0将RpcContext分成ServerContext、ServerAttachment、ClientAttachment、ServiceContext,有点不太清楚他们分别的应用场景,ServerAttachment和ServerContext的差异是?ServiceContext的定位是?看代码注解没太看明白,大佬有空帮忙解答下


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] EarthChen closed issue #8738: [3.0] Attachment is lost when calling without registry

Posted by GitBox <gi...@apache.org>.
EarthChen closed issue #8738:
URL: https://github.com/apache/dubbo/issues/8738


   


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] fengcunhan edited a comment on issue #8738: [3.0] Attachment is lost when calling without registry

Posted by GitBox <gi...@apache.org>.
fengcunhan edited a comment on issue #8738:
URL: https://github.com/apache/dubbo/issues/8738#issuecomment-916780084


   你使用错了API,如果要获取服务器端带来的参数,应该使用RpcContext.getServerContext()
   
   `public void attachmentTest() {
           final String key = "user-attachment";
           final String value = "attachment-value";
           RpcContext.removeClientAttachment();
           RpcContext.getClientAttachment().setAttachment(key, value);
           delegate.greetWithAttachment(GreeterRequest.newBuilder().setName("meta").build());
           final String returned = (String) RpcContext.**getServerContext**().getObjectAttachment(key);
           Assert.assertEquals(value, returned);
       } `


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] EarthChen commented on issue #8738: [3.0] Attachment is lost when calling without registry

Posted by GitBox <gi...@apache.org>.
EarthChen commented on issue #8738:
URL: https://github.com/apache/dubbo/issues/8738#issuecomment-916564713


   > ![image](https://user-images.githubusercontent.com/39434627/132783707-45ba27b1-0c93-4025-9438-bd60dc4bb7d0.png)
   > 
   > @AlbumenJ 这两段代码有些矛盾,finally已经将context清空了,onResponse再设置也没啥意义
   > 
   > 3.0将RpcContext分成ServerContext、ServerAttachment、ClientAttachment、ServiceContext,有点不太清楚他们分别的应用场景,ServerAttachment和ServerContext的差异是?ServiceContext的定位是?看代码注解没太看明白,大佬有空帮忙解答下
   
   consumer 端需要看ConsumerContextFilter  
   provider 端是 ContextFilter


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] EarthChen commented on issue #8738: [3.0] Attachment is lost when calling without registry

Posted by GitBox <gi...@apache.org>.
EarthChen commented on issue #8738:
URL: https://github.com/apache/dubbo/issues/8738#issuecomment-916842389


   tri协议部分已经拿到了attach  。
   问题在consumercontextfilter。。


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org