chickenlj opened a new pull request #1876: [Dubbo-606] Optimize new async 
support for both consumer and provider side.
URL: https://github.com/apache/incubator-dubbo/pull/1876
 
 
   ## What is the purpose of the change
   
   Async support for provider and consumer.
   * Consumer, support method with extra Future return type
   ```java
   @AsyncFor(GreetingsServices.class)
   public interface GreetingsServiceAsync extends GreetingsServices {
       CompletableFuture<String> sayHi(String name);
   }
   ```
   We also provide a tool to do that: 
[dubbo-async-processor](https://github.com/dubbo/dubbo-async-processor)  
   * Provider, support async like what Servlet 3.0 async works.
   ```java
   public class AsyncServiceImpl implements AsyncService {
   
       public String sayHello(String name) {
           System.out.println("Main sayHello() method start.");
           final AsyncContext asyncContext = RpcContext.startAsync();
           new Thread(() -> {
               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;
       }
   }
   ```
   
   Drawbacks and following enhancements:
   * For both consumer and provider async, response can't be processed with 
Filter chains anymore.
   
   Thanks for @yuyijq for contributing code and ideas with #606.
   
   ## Brief changelog
   
   
   
   ## Verifying this change
   
   This change has been deploy to central maven repository with a 
2.6.3-SNAPSHOT version. You can see details of how to use from these two 
projects:
   [dubbo-async-processor](https://github.com/dubbo/dubbo-async-processor)  
   [dubbo-samples](https://github.com/dubbo/dubbo-samples)  
   
   Follow this checklist to help us incorporate your contribution quickly and 
easily:
   
   - [x] Make sure there is a 
[GITHUB_issue](https://github.com/apache/incubator-dubbo/issues) filed for the 
change (usually before you start working on it). Trivial changes like typos do 
not require a GITHUB issue. Your pull request should address just this issue, 
without pulling in other changes - one PR resolves one issue.
   - [x] Format the pull request title like `[Dubbo-XXX] Fix UnknownException 
when host config not exist #XXX`. Each commit in the pull request should have a 
meaningful subject line and body.
   - [x] Write a pull request description that is detailed enough to understand 
what the pull request does, how, and why.
   - [ ] Write necessary unit-test to verify your logic correction, more mock a 
little better when cross module dependency exist. If the new feature or 
significant change is committed, please remember to add integration-test in 
[test module](https://github.com/alibaba/dubbo/tree/master/dubbo-test).
   - [x] Run `mvn clean install -DskipTests` & `mvn clean test-compile 
failsafe:integration-test` to make sure unit-test and integration-test pass.
   - [x] If this contribution is large, please follow the [Software Donation 
Guide](https://github.com/apache/incubator-dubbo/wiki/Software-donation-guide).
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to