I am using the AWS SDK for Java 2.0, together with the Netty HTTP client, and I noticed that there are two different thread pools that can effectively handle a response. The first one is a ThreadPoolExecutor that can be overriden as part of the service client itself like so
DynamoDbAsyncClient dynamoClient = DynamoDbAsyncClient.builder()
.httpClient(httpClient)
.asyncConfiguration(ClientAsyncConfiguration.builder()
.advancedOption(SdkAdvancedAsyncClientOption.FUTURE_COMPLETION_EXECUTOR, awsSdkFutureCompletionExecutor)
.build())
The second one is the Netty HTTP client's event loop. Depending on where I join the thread, I can see that it is either processed by the aws-java-sdk-NettyEventLoop
or the sdk-async-response
thread pool.
If I call dynamoClient.query(request).join()
I can see that the aws-java-sdk-NettyEventLoop
continues any further processing, whereas dynamoClient.query(request).whenComplete(...)
means that the sdk-async-response
thread is doing the processing.
Is there a recommended approach? Should I prefer to do the processing in one thread pool over the other?