aliyun-openapi-java-sdk icon indicating copy to clipboard operation
aliyun-openapi-java-sdk copied to clipboard

Async support for java SDK

Open prbobba opened this issue 9 years ago • 4 comments

Hi Team

Is there any plan to introduce Async client libraries for Java ?

Thanks Praneeth

prbobba avatar Nov 20 '17 06:11 prbobba

Hi,Thanks for your feedback. The Java SDK does not support async client by default. Your suggestion is already in our work plan, but it will take some time. If you are anxious to use, you can try to rewrite it as follows:

  1. Select ApacheHttpClient to support async client.
 public void getDefaultAcsClient() throws ServerException, ClientException {
        HttpClientConfig httpClientConfig = HttpClientConfig.getDefault();
        httpClientConfig.setClientType(HttpClientType.ApacheHttpClient);
        IClientProfile profile = DefaultProfile.getProfile(regionId, accesskeyId, accesskeySecret);
        profile.setHttpClientConfig(httpClientConfig);
        return new DefaultAcsClient(profile);
  }
  1. then override the getAcsResponse() method.
    private <T extends AcsResponse> HttpResponse getAcsResponse(AcsRequest<T> request, boolean 
        autoRetry, int maxRetryNumber, String regionId, AlibabaCloudCredentials credentials, Signer 
        signer, FormatType format, Callback callback){
        // Omitted code
        response = this.getDefaultAcsClient().asyncInvoke(httpRequest, callback);
        // Omitted code
     }

Thanks again for your suggestions and feedback, Wish you a happy life!

ssy352959096 avatar Feb 26 '19 06:02 ssy352959096

Thanks for the response!

prbobba avatar Mar 02 '19 11:03 prbobba

Hello! Is the async client be implemented currently? I looked at the code and find that the DefaultAcsClient does not have asyncInvoke methods but IHttpClient does. The getAcsResponse method now calls doAction (that calls other overloaded doActions and finally doRealAction, the callee of IHttpClient), which makes the code mentioned above not working anymore.

balthild avatar Jun 06 '20 20:06 balthild

I need the same information

lordigon avatar Jul 21 '21 15:07 lordigon