When I create a dynamodb table, I try to use waiters to wait AWS service to complete its action.
CreateTableRequest createRequest = new CreateTableRequest()
.withTableName(tableName);
CreateTableResult createResult = dynamoDbClient.createTable(createRequest);
dynamoDbClient.waiters().tableExists().run(() -> new DescribeTableRequest(tableName));
return dynamoDB.getTable(tableName);
But I get:
incompatible types: com.amazonaws.waiters.WaiterParameters is not a functional interface
I’m new to Java, what’s a functional interface? How can I get around this problem?
2
Answers
Dividing into 2 rows seems to solve the problem:
Use AWS SDK for Java V2, not the AWS SDK for Java V1 – which is no longer recommended to use as specified on this AWS page.
You can use Waiters easily using the Amazon Dynamo V2 API. See this code example.
To read more about waiter and the AWS SDK for Java V2, see:
Using waiters in the AWS SDK for Java 2.x