Database Reference
In-Depth Information
Transaction library
The Transaction library has been built on top of the AWS SDK for Java and is only avail-
able for Java-based applications. This client library has been provided in order to reduce
the development efforts one has to put in to support atomic operations. For those who are
not aware of what a transaction means, consider an example where you need to perform
two to three operations one after another and commit them only when all the operations are
successful. If any of the operations fails in between, the complete process should be failed,
reverting all the operations before the failed operation.
The Transaction library supports atomic writes and isolated reads. Let's try to understand
these one by one. It would not be an exaggeration if I were to say this library brings Dy-
namoDB to completion by supporting atomicity, consistency , isolation, and durability
(ACID properties) with regards to multiple items.
Atomic writes
A good example of a transaction is online money transfer from one bank account to another
bank account. It consists of various stages that are as follows:
• Initiating money transfer from bank account A
• Deducting money from bank account A
• Getting interbank money transfer clearance
• Depositing money to bank account B
• Notifying both account holders about the transaction
Here, it is very important that the set of instructions gets completed. Suppose any one oper-
ation fails, then all previous operations should be reverted to their original state. The opera-
tions should fail or succeed as a unit. If this does not happen, then the system would be in
the wrong state.
In order to solve this problem, Amazon has given us the Transaction library, which helps
perform atomic operations. The library is quite easy to use. It needs two DynamoDB tables
with minimal read and writes provisioned capacity units that keep track of the operations
within a transaction. The first table stores the transaction, while the second one stores the
pretransaction image of items involved in that transaction.
1. To begin with, you need to first create an Amazon DynamoDB client. You also
need to have two tables created in your DynamoDB console to be used by the
Transaction library.
Search WWH ::




Custom Search