[Q/A]The parameters in Dubbo's RPC calls are passed by value. #15372
Closed
SpringStudent
started this conversation in
General
Replies: 1 comment
-
|
In a RPC system, request and response are being serialized into bytes. So, you cannot change the request in provider side. https://dubbo.apache.org/en/overview/mannual/java-sdk/tasks/framework/attachment/ |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Pre-check
Apache Dubbo Component
Java SDK (apache/dubbo)
Details
While working on Service A today, I found that the return value of a method in Service B did not meet the requirements. However, this interface method is already referenced in many places, so changing its return value would inevitably affect multiple consumers.
Then I looked at the method signature and noticed that it takes a Map as a parameter. So I thought—why not modify this method in Service B to put the result that Service A needs into the input Map? That way, after Service A calls Service B, it can retrieve the result from the Map. Here's some pseudocode:
This raises a question: Since RPC method parameters are passed by value, is it possible to support pass-by-reference? If not, then the description that RPC can call remote services just like local methods might be somewhat misleading(The parameters in Java method local calls support both value passing and reference passing).
译文
今天在写服务A时,发现服务B的方法返回值不满足要求。这个接口方法已经被很多地方引用,如果修改方法返回值势必会影响多个消费方。于是看了下方法签名,方法的参数传递的是一个Map对象,于是就设想调整一下服务B的该方法,将服务A想要的结果放到入参Map不就行了吗,这样服务A的调用服务B结束再从参数中获取服务B放入的结果不就行了吗,伪代码如下
这就涉及到一个问题,Rpc的方法调用参数是值传递,那么是否可以支持方法调用参数为引用传递。如果不能做到,那么像调用本地方法一样调用远程服务的描述是否有些歧义(java方法本地调用参数既支持值传递也支持引用传递的)。
Code of Conduct
Beta Was this translation helpful? Give feedback.
All reactions