Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Aws sdk for java, dynamo db mapper async

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

like image 604
Ulisse Avatar asked Aug 01 '13 09:08

Ulisse


2 Answers

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

like image 179
Ahmad Abdelghany Avatar answered Sep 20 '22 21:09

Ahmad Abdelghany


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.

like image 35
Jason Fulghum Avatar answered Sep 19 '22 21:09

Jason Fulghum