검색

5.2. TransactionManager 오브젝트 사용

download PDF

javax. Cryostat.TransactionManager 오브젝트를 사용하는 가장 일반적인 방법은 프레임워크 API(예: Camel JMS 구성 요소)에 전달하는 것입니다. 이를 통해 프레임워크에서 트랜잭션 혼동을 확인할 수 있습니다. 경우에 따라 TransactionManager 개체를 직접 사용하려는 경우가 있습니다. 이 기능은 suspend()resume() 메서드와 같은 고급 트랜잭션 API에 액세스해야 하는 경우에 유용합니다.

5.2.1. TransactionManager 인터페이스 정의

JTA TransactionManager 인터페이스에는 다음과 같은 정의가 있습니다.

interface javax.transaction.TransactionManager {

    // Same as UserTransaction methods

    public void begin();

    public void commit();

    public void rollback();

    public void setRollbackOnly();

    public int getStatus();

    public void setTransactionTimeout(int seconds);

    // Extra TransactionManager methods

    public Transaction getTransaction();

    public Transaction suspend() ;

    public void resume(Transaction tobj);
}

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.
Red Hat logoGithubRedditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

© 2024 Red Hat, Inc.