In the Amazon Web Services sdk for java there is the possibility to create two different clients for DynamoDB: sync and async. The two objects can be then passed to the constructor of DynamoDBMapper. So, you should be able to create two different kinds of DynamoDBMapper: sync mapper and async mapper.
My question is: how does the async mapper work? I can't find any method in the async mapper that returns a Future object. So, how could I ever run multiple query asynchronously if I must always wait the return value of any method of the async mapper?
Thanks
This is now supported by the enhanced DynamoDB client that comes with aws-sdk-java-v2
First, create an async version of the EnhancedClient & Table objects:
DynamoDbEnhancedAsyncClient enhancedClient = DynamoDbEnhancedAsyncClient.create();
DynamoDbAsyncTable<Customer> customerTable =
enhancedClient.table("customers_table", TableSchema.fromBean(Customer.class));
Then, you can perform operations on it asynchronously:
CompletableFuture<Customer> result = customerTable.getItem(r -> r.key(customerKey));
For more details see asynchronous-operations
The asynchronous DynamoDB client extends from the synchronous client, and provides new method names for the asynchronous operations that return Futures. Currently the DynamoDBMapper will always use the synchronous methods of whatever AmazonDynamoDB client that you pass in. We'll take this feedback as a feature request for asynchronous support using the mapper.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With