Transaction policy based on Java Transaction Model

Source: Internet
Author: User

[Guide] Transactions are crucial to ensuring data integrity and consistency. To fully understand transactions, you must be familiar with some basic concepts, models, and strategies. "Obfuscation of Transaction Models and transaction policies is a common error," Mark Richard said ".

 

Transactions are crucial to ensuring data integrity and consistency. To fully understand transactions, you must be familiar with some basic concepts, models, and strategies. "Obfuscation of Transaction Models and transaction policies is a common error," Mark Richard said ". This article talks about the three transaction models supported by the Java platform and discusses the four major transaction strategies based on these models. Some examples of using Spring framework and Enterprise JavaBeans (EJB) 3.0 are as follows, mark describes how the transaction model works and how it can serve as the cornerstone from basic transaction processing to high-speed transaction processing systems ".

The Java platform supports three transaction models:

* Local transaction model-transactions are managed by DB resources rather than application containers or frameworks. Developers manage connections rather than transactions.

* Programmatic transaction model-the developer obtains the transaction from the Transaction Manager and then needs to write the startup, commit, exception, and rollback code of the transaction.

* Declarative transaction model-the most common model, also known as container management transactions. In this model, containers manage transactions and developers Define (declare) the behaviors and parameters of transactions.

However, this support can only describe the basic information and expected behaviors of transactions, as well as the syntax and rules used. The transaction policy can solve the following problems: when to use the required or mandatory attributes, specific commands, which model to use, and how to optimize specific conditions.

Mark discussed the advantages and traps of the transaction model in a previous article.

This article describes how to use a specific model and how to use it in an appropriate way. The four policies are listed below:

* When the client sends multiple server-or model-based calls to complete a separate work order element, you must use the client orchestration transaction policy.

* When the main interface method for backend calls is coarse-grained (if you want to call it as a service), you need to use the API-layer transaction policy.

* A High-concurrency transaction policy is a variant of the preceding policy. This policy is usually used when the application cannot support long transactions (based on performance and scalability considerations ).

* High-speed transaction processing is perhaps the most extreme transaction strategy. This policy can be used if the application requires the fastest processing time (and throughput) while maintaining a certain degree of Atomicity in the processing process.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.