There are three forms of Dubbo result return 1. Asynchronous no return result 2. Asynchronous return result 3. Synchronous return result // The code starts from line 82 in DubboInvoker.java
The third synchronization has a return result
The processing flow is as follows:
1.currentClient.request(inv, timeout).get() Use currentClient.request(inv, timeout) in the synchronous call to send the netty request, return a DefaultFuture object, and call the get method of DefaultFuture
2. In DefaultFuture.get(int timeout), the isDone() method is used to determine whether there is a result returned from the service provider; if there is no return, first record the current time, acquire the thread lock, and use while(!isDone) Do the loop judgment, when the provider still has no return result, done.await(timeout, TimeUnit.MILLISECONDS); jump out of the loop when there is a return result or there is a timeout; when there is still no return result from the provider, throw TimeoutException, and finally To judge the return result, when res.getStatus() == Response.CLIENT_TIMEOUT || res.getStatus() == Response.SERVER_TIMEOUT, TimeoutException will be thrown.
3. The doReceived method in DefaultFuture is responsible for giving the response after receiving the return from the provider, and done.signal()