5.2. TransactionManager 오브젝트 사용
javax. Cryostat.TransactionManager
오브젝트를 사용하는 가장 일반적인 방법은 프레임워크 API(예: Camel JMS 구성 요소)에 전달하는 것입니다. 이를 통해 프레임워크에서 트랜잭션 혼동을 확인할 수 있습니다. 경우에 따라 TransactionManager
개체를 직접 사용하려는 경우가 있습니다. 이 기능은 suspend()
및 resume()
메서드와 같은 고급 트랜잭션 API에 액세스해야 하는 경우에 유용합니다.
5.2.1. TransactionManager 인터페이스 정의 링크 복사링크가 클립보드에 복사되었습니다!
JTA TransactionManager 인터페이스에는 다음과 같은 정의가 있습니다.
5.2.2. TransactionManager 메서드 설명 링크 복사링크가 클립보드에 복사되었습니다!
TransactionManager
인터페이스는 UserTransaction
인터페이스에 있는 모든 메서드를 지원합니다. TransactionManager
오브젝트를 트랜잭션 분리에 사용할 수 있습니다. 또한 TransactionManager
오브젝트는 다음 메서드를 지원합니다.
- getTransaction()
-
현재 스레드와 연결된 트랜잭션인 현재 트랜잭션에 대한 참조를 가져옵니다.Gets a reference to the current transaction, which is the transaction that is associated with the current thread. 현재 트랜잭션이 없는 경우 이 메서드는
null
을 반환합니다. - suspend()
현재 스레드에서 현재 트랜잭션을 분리하고 트랜잭션에 대한 참조를 반환합니다.Detaches the current transaction from the current thread and returns a reference to the transaction. 이 메서드를 호출한 후 현재 스레드에 더 이상 트랜잭션 컨텍스트가 없습니다.After calling this method, the current thread no longer has a transaction context. 이 시점 이후에 수행하는 작업은 더 이상 트랜잭션 컨텍스트에서 수행되지 않습니다.
참고모든 트랜잭션 관리자가 트랜잭션 일시 중지를 지원하지는 않습니다. 그러나 이 기능은 나레이나에서 지원합니다.
- resume()
- 일시 중지된 트랜잭션을 현재 스레드 컨텍스트에 다시 연결합니다. 이 메서드를 호출한 후 트랜잭션 컨텍스트가 복원되고 이 시점 이후의 모든 작업이 트랜잭션 컨텍스트에서 수행됩니다.After calling this method, the transaction context is restored and any work that you do after this point is done in the context of a transaction.