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/07/29 03:08:18 UTC

[GitHub] [dubbo] pangshuqiang opened a new issue #8365: Dubbo3.0.1,提示`RpcContext.getContext()`已过期,更换`RpcContext.getServerContext()` 缺无法获取到值

pangshuqiang opened a new issue #8365:
URL: https://github.com/apache/dubbo/issues/8365


   - [* ] 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.1
   * Operating System version: all
   * Java version: 11
   
   ### Steps to reproduce this issue
   
   1. 在Dubbo3.0.1,对 `RpcContext.getContext()` 提示` 'getContext()' 已经过时了`;
   2. 更换成 `RpcContext.getServerContext()` ,在Consumer设置setAttachment值,从Provider获取getAttachment值为空 null ;
   
   Consumer
   ![图片](https://user-images.githubusercontent.com/28327645/127425198-85e54845-8d57-4b63-b077-6457539dd271.png)
   
   ![图片](https://user-images.githubusercontent.com/28327645/127425037-b3b2a397-ba5f-4c03-ab01-2a8b5bd1e66b.png)
   
   Provider
   ![图片](https://user-images.githubusercontent.com/28327645/127425235-d0ca8e61-4f4d-4409-b728-fd51b8eb8a9d.png)
   
   ![图片](https://user-images.githubusercontent.com/28327645/127424539-47df3263-a6d2-4201-8acd-7c323fc4245b.png)
   
   不知道是不是我使用的 “RpcContext.getServerContext()” 不对?还是说新版的需要通过实现Listener才行?
   
   还望指点指点,谢谢。
   


-- 
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] pangshuqiang commented on issue #8365: Dubbo3.0.1,提示`RpcContext.getContext()`已过期,更换`RpcContext.getServerContext()` 缺无法获取到值

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


   > 
   > 
   > Consumer 端使用 getClientAttachment,Provider 端使用 getServerAttachment,Consumer 端获取 Provider 端返回上下文使用 getServerContext。
   > 
   > getClientAttachment ( A --> B , in A side)
   > getServerAttachment ( A --> B , in B side)
   > getServerContext ( A <-- B , in B side)
   
   
   
   > 
   > 
   > Consumer 端的 ClientAttachment 会传递到 Provider 端的 ServerAttachment,Provider 端的 ServerContext 会传递回 Consumer 端的 ServerContext
   
   谢谢,昨天也测试过 Consumer 端通过 getClientAttachment.setAttachment 传递,在 Provider 端通过 getServerAttachment.getAttachment 获取值,也是没能拿到,我当时也觉得纳闷,估计是撸码头晕了,回头我再试一次,再次感谢。


-- 
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] CrazyHZM closed issue #8365: Dubbo3.0.1,提示`RpcContext.getContext()`已过期,更换`RpcContext.getServerContext()` 缺无法获取到值

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


   


-- 
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] AlbumenJ commented on issue #8365: Dubbo3.0.1,提示`RpcContext.getContext()`已过期,更换`RpcContext.getServerContext()` 缺无法获取到值

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


   Consumer 端的 ClientAttachment 会传递到 Provider 端的 ServerAttachment,Provider 端的 ServerContext 会传递回 Consumer 端的 ServerContext


-- 
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] pangshuqiang commented on issue #8365: Dubbo3.0.1,提示`RpcContext.getContext()`已过期,更换`RpcContext.getServerContext()` 缺无法获取到值

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


   ### 》》》》》 Consumer 端的 ClientAttachment 会传递到 Provider 端的 ServerAttachment,Provider 端的 ServerContext 会传回递 Consumer 端的 Result
   
   补充一下测试结果,如下:
   
   /******* Consumer setValue --> Provider  getValue *********/
   **Consumer:**`RpcContext.getClientAttachment().setAttachment(WebConstEnum.Model.TP_NUM, MDC.get(WebConstEnum.Model.TP_NUM));`
   **Provider :**`RpcContext.getServerAttachment().getAttachment(WebConstEnum.Model.TP_NUM);`
   
   /******** Provider  setValue --> Consumer getValue *********/
   **Provider :** `result.setAttachment(WebConstEnum.Model.TIMESTAMP, "" + l);`  
   or `RpcContext.getServerContext().setAttachment(WebConstEnum.Model.TIMESTAMP, ""+System.currentTimeMillis());`
   **Consumer:**`result.getAttachment(WebConstEnum.Model.TIMESTAMP, "-1");`
   
   非常感谢 @AlbumenJ ,thank you!


-- 
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] CrazyHZM commented on issue #8365: Dubbo3.0.1,提示`RpcContext.getContext()`已过期,更换`RpcContext.getServerContext()` 缺无法获取到值

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


   @pangshuqiang 
   I think the problem has been resolved, please close issues temporarily, if you have other issues, you can reopen issues


-- 
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] AlbumenJ commented on issue #8365: Dubbo3.0.1,提示`RpcContext.getContext()`已过期,更换`RpcContext.getServerContext()` 缺无法获取到值

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


   Consumer 端使用 getClientAttachment,Provider 端使用 getServerAttachment,Consumer 端获取 Provider 端返回上下文使用 getServerContext。
   
   getClientAttachment ( A --> B , in A side)
   getServerAttachment ( A --> B , in B side)
   getServerContext ( A <-- B , in B side)


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