Key Attributes of Spring Transactions
by, 11-27-2011 at 11:25 PM (1046 Views)
Transactions are defined as doing a business unit of work. It is a key functionality that enable you to control concurrent access of data by multiple business operations. This is done in order to safeguard integrity and ensure that data remains in a consistent state. If for any reason the unit of work could not be completed as an indivisible unit of work, all the changes are unwound and the system is returned to its previous state. The key properties for the design of any application is to ensure that these properties are well implemented in your transactions.
These concepts of transactions are known as ACID: Atomicity, Consistency, Isolation, and Durability.
To give you an idea of what this would look like in your application, below is some pseudo code that is consistent with these properties:
- Begin transaction
- Deduct inventory (sql write)
- Debit client bank account (sql write)
- Credit business funds (sql write)
- Update transaction log (sql write)
- Commit transaction
In a future tip, I will look more depth at how you can use this in Spring with your application server.