Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.이 콘텐츠는 선택한 언어로 제공되지 않습니다.
2.4. PlatformTransactionManager Interface
Overview 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
The
PlatformTransactionManager
interface is the key abstraction in the Spring transaction API, providing the classic transaction client operations: begin, commit and rollback. This interface thus provides the essential methods for controlling transactions at run time.
Note
The other key aspect of any transaction system is the API for implementing transactional resources. But transactional resources are generally implemented by the underlying database, so this aspect of transactional programming is rarely a concern for the application programmer.
PlatformTransactionManager interface 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
Example 2.1, “The PlatformTransactionManager Interface” shows the definition of the
org.springframework.transaction.PlatformTransactionManager
interface.
Example 2.1. The PlatformTransactionManager Interface
TransactionDefinition interface 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
The
TransactionDefinition
interface is used to specify the characteristics of a newly created transaction. It is used to specify the isolation level and the propagation policy of the new transaction. For more details, see Section 5.3, “Propagation Policies”.
TransactionStatus interface 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
The
TransactionStatus
interface can be used to check the status of the current transaction (that is, the transaction associated with the current thread) and to mark the current transaction for rollback. It is defined as follows:
Using the PlatformTransactionManager interface 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
The
PlatformTransactionManager
interface defines the following methods:
-
getTransaction()
- Create a new transaction and associate it with the current thread, passing in a
TransactionDefinition
object to define the characteristics of the new transaction. This is analogous to the begin() method of many other transaction client APIs. -
commit()
- Commit the current transaction, making permanent all of the pending changes to the registered resources.
-
rollback()
- Roll back the current transaction, undoing all of the pending changes to the registered resources.
Generally, you do not use the
PlatformTransactionManager
interface directly. In Apache Camel, you typically use a transaction manager as follows:
- Create an instance of a transaction manager (there are several different implementations available in Spring—see Section 2.5, “Transaction Manager Implementations”).
- Pass the transaction manager instance either to a Apache Camel component or to the
transacted()
DSL command in a route. The transactional component or thetransacted()
command is then responsible for demarcating transactions (see Chapter 5, Transaction Demarcation).