Replies: 2 comments
-
Hi @akotnana the link you referenced is for Java SDK v2 (not Java SDK v1), and yes it's for regular client requests, not DynamoDBMapper requests. I don't think there's a way to customize the timeouts on a request-level for DynamoDBMapper, unfortunately. |
Beta Was this translation helpful? Give feedback.
-
Hi, Thanks for the response. Sorry, I meant to link it for SDK v1. Anyways, I think I found a solution that could work: creating a request handler for the DDB client that assigns different timeouts based on what AmazonWebServiceRequest the request is using. For example: public class PerDynamoDBOperationTimeoutHandler extends RequestHandler2 {
// single-request timeout, overall-request timeout
public static final Map<Class<? extends AmazonWebServiceRequest>, Pair<Integer, Integer>> REQUEST_TO_TIMEOUT_MAPPING =
new ImmutableMap.Builder<Class<? extends AmazonWebServiceRequest>, Pair<Integer, Integer>>()
.put(ListTablesRequest.class, Pair.of(5, 20))
.put(DescribeTableRequest.class, Pair.of(10, 40))
.build();
@Override
public void beforeRequest(Request<?> request) {
if (REQUEST_TO_TIMEOUT_MAPPING.containsKey(request.getOriginalRequest().getClass())) {
Pair<Integer, Integer> timeouts = REQUEST_TO_TIMEOUT_MAPPING.get(request.getOriginalRequest().getClass());
originalRequest.setSdkRequestTimeout(timeouts.getLeft());
originalRequest.setSdkClientExecutionTimeout(timeouts.getRight());
}
}
} And after adding this request handler to the DDB client, we can just wrap this DDB client with a DynamoDBMapper. Let me know if this seems like it could work. |
Beta Was this translation helpful? Give feedback.
-
I'm wondering if there is a way to implement socket timeouts, request timeouts, or client execution timeouts on the operation-level on the DynamoDBMapper. For example, I want a low socket timeout for GetItem/PutItem operations, while a higher socket timeout for scans/queries. This would translate to DynamoDBMapper.save/load or scan/query.
I saw https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/core/RequestOverrideConfiguration.html, but it looks like this is only relevant for DynamoDB client requests, not for requests made via the DynamoDBMapper.
Beta Was this translation helpful? Give feedback.
All reactions