[Q/A]How does provider response attachments to consumer in Dubbo2.7.18? #13918
Replies: 1 comment
-
|
Please re-submit the discussion in English :) |
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
provider:
public class MyGenericService implements GenericService {
public Object $invoke(String methodName, String[] parameterTypes, Object[] args) throws GenericException {
RpcContext serverContext = RpcContext.getServerContext();
serverContext.setAttachment("key","value");
return "xxxx";
}
consumer:
...
registryConfig.setAddress("N/A");
...
referenceConfig.setUrl("dubbo://localhost:8888");
referenceConfig.get().$invoke("echo", new String[]{"java.lang.String"}, new String[]{body});
RpcContext.getServerContext().getAttachment("key");
——————
My code snippet is shown above,
I cannot get the value of the attachment "key" on the consumer side. How should I return attachments from the provider to the consumer?
(For some special reasons, only dubbo2 can be used for the time being)
在consumer端拿不到的“key”的值,请问应该怎么在provider端向consumer端回传隐式参数?
(因为某些特殊原因,暂时只能使用dubbo2)
Code of Conduct
Beta Was this translation helpful? Give feedback.
All reactions