Async support for java SDK
Hi Team
Is there any plan to introduce Async client libraries for Java ?
Thanks Praneeth
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:
- 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);
}
- 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!
Thanks for the response!
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.
I need the same information