Book Image

DynamoDB Cookbook

By : Tanmay Deshpande
Book Image

DynamoDB Cookbook

By: Tanmay Deshpande

Overview of this book

Table of Contents (18 chapters)
DynamoDB Cookbook
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Performing asynchronous requests to DynamoDB


Until now, we have used a synchronous DynamoDB client to make requests to DynamoDB. Synchronous requests block the thread unless the operation is not performed. Due to network issues, sometimes it can be difficult for the operation to get completed quickly. In that case, we can go for asynchronous client requests so that we submit the requests and do some other work.

Getting ready

To get started with this recipe, you should have your workstation ready with the Eclipse IDE.

How to do it…

Asynchronous client is easy to use:

  1. First, we need to instantiate the AmazonDynamoDBAsync class:

    AmazonDynamoDBAsync dynamoDBAsync = new AmazonDynamoDBAsyncClient(new ProfileCredentialsProvider());
  2. Next, we need to create the request to be performed in an asynchronous manner. Let's say that we need to delete a certain item from our product table. Then, we can create the DeleteItemRequest, as shown in the following code snippet:

    Map<String, AttributeValue> key = new...