Does provider "async = true" need to be remove from url when register to registry?
See original GitHub issue- I have searched the issues of this repository and believe that this is not a duplicate.
- I have checked the FAQ of this repository and believe that this is not a duplicate.
Environment
- Dubbo version: 2.7.0-SNAPSHOT
Step to reproduce this issue
private URL getRegisteredProviderUrl(final Invoker<?> originInvoker) {
URL providerUrl = getProviderUrl(originInvoker);
//The address you see at the registry
return providerUrl.removeParameters(getFilteredKeys(providerUrl))
.removeParameter(Constants.MONITOR_KEY)
.removeParameter(Constants.BIND_IP_KEY)
.removeParameter(Constants.BIND_PORT_KEY)
.removeParameter(QOS_ENABLE)
.removeParameter(QOS_PORT)
.removeParameter(ACCEPT_FOREIGN_IP)
.removeParameter(VALIDATION_KEY)
.removeParameter(INTERFACES);
}
TO
private URL getRegisteredProviderUrl(final Invoker<?> originInvoker) {
URL providerUrl = getProviderUrl(originInvoker);
// 此处移除async标记,仅保留标记在provider端
Set<String> keySet = providerUrl.getParameters().keySet();
List<String> asyncKey = new ArrayList<>();
for(String key : keySet) {
if(key.endsWith("." + Constants.ASYNC_KEY) || key.equals(Constants.ASYNC_KEY)) {
asyncKey.add(key);
}
}
//The address you see at the registry
return providerUrl.removeParameters(getFilteredKeys(providerUrl))
.removeParameter(Constants.MONITOR_KEY)
.removeParameter(Constants.BIND_IP_KEY)
.removeParameter(Constants.BIND_PORT_KEY)
.removeParameter(QOS_ENABLE)
.removeParameter(QOS_PORT)
.removeParameter(ACCEPT_FOREIGN_IP)
.removeParameter(VALIDATION_KEY)
.removeParameter(INTERFACES)
.removeParameters(asyncKey);
}
that if Provider use “provider async” like this:
public String sayHello(String name) {
System.out.println("Main sayHello() method start.");
final AsyncContext asyncContext = RpcContext.startAsync();
new Thread(() -> {
asyncContext.signalContextSwitch();
System.out.println("Attachment from consumer: " + RpcContext.getContext().getAttachment("consumer-key1"));
System.out.println(" -- Async start.");
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
asyncContext.write("Hello " + name + ", response from provider.");
System.out.println(" -- Async end.");
}).start();
System.out.println("Main sayHello() method end.");
return "hello, " + name;
}
<dubbo:method name="sayHello" async="true"/>
and consumer user dubbo version low than 2.7.0-SNAPSHOT, “async = true” will know from provider registed url, that need consumer use old async to invoke this method. But it is not what we expected, we think async should only be set by consumer itself. 英文不太好,中文版:
- Provider版本使用 2.7.0-SNAPSHOT版本,然后发布接口使用了"provider async"的方式(见上面第二段代码),则需要在发布的时候添加
<dubbo:method name="sayHello" async="true"/>
则会将 async=true 的标记注册到注册中心,这时候就会将标记透传到 Consumer 端,导致服务调用变成异步的,而出现返回值为 null 的情况。 - 根据我个人的理解,async 标记应该仅由 provider 或 consumer 自己指定,而不应该透传到对方感知。
Issue Analytics
- State:
- Created 5 years ago
- Comments:16 (9 by maintainers)
Top Results From Across the Web
subject:"\[GitHub\] diecui1202 commented on issue #2321\: Does ...
diecui1202 commented on issue #2321: Does provider "async = true" need to be remove from url when register to registry?
Read more >Introduction to Identity on ASP.NET Core | Microsoft Learn
Use Identity with an ASP.NET Core app. Learn how to set password requirements (RequireDigit, RequiredLength, RequiredUniqueChars, and more).
Read more >Email Confirmation with ASP.NET Core Identity - Code Maze
In this article, we are going to learn how to enable email confirmation during the registration process with ASP.NET Core Identity.
Read more >React + Redux - User Registration and Login Tutorial & Example
In this tutorial we'll cover how to implement user registration and login functionality with React and Redux. The tutorial example is a ...
Read more >AuthSession - Expo Documentation
Get the URL that your authentication provider needs to redirect to. For example: https://auth.expo.io/@your-username/your-app-slug . You can pass an additional ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@carryxyh 如果在 Consumer 端移除该属性,则有一点要求是 provider 必须在 consumer 后面升级,否则会将标记透传过去,造成consumer 端变成异步调用。
We are working on this in branch dev-meta.
I have seen that you fixed this part in #2434. I tend to merge it now.