question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

  1. https://github.com/apache/incubator-dubbo/blob/master/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocol.java
 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. 英文不太好,中文版:

  1. Provider版本使用 2.7.0-SNAPSHOT版本,然后发布接口使用了"provider async"的方式(见上面第二段代码),则需要在发布的时候添加 <dubbo:method name="sayHello" async="true"/>则会将 async=true 的标记注册到注册中心,这时候就会将标记透传到 Consumer 端,导致服务调用变成异步的,而出现返回值为 null 的情况。
  2. 根据我个人的理解,async 标记应该仅由 provider 或 consumer 自己指定,而不应该透传到对方感知。

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
fingthinkingcommented, Sep 10, 2018

@carryxyh 如果在 Consumer 端移除该属性,则有一点要求是 provider 必须在 consumer 后面升级,否则会将标记透传过去,造成consumer 端变成异步调用。

0reactions
chickenljcommented, Sep 19, 2018

Therefore, for compatibility reasons, it is necessary to fix the problem on the Provider side so that method.async is not registered to the registry.

We are working on this in branch dev-meta.

In the Consumer, ignoring the Provider’s method.async is equivalent to an insurance, ensuring that the Provider’s method.async will not affect the Consumer’s behavior under any circumstances.

I have seen that you fixed this part in #2434. I tend to merge it now.

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found