2010-06-07 4 views
1

커밋 (IEnlistmentNotification 구현)이 호출되면 트랜잭션을 롤백하려는 예외를 throw 할 수 있습니까?IEnlistmentNotification 인터페이스의 2 단계 커밋

+2

너무 늦게 롤백을위한 것입니다. –

+0

사실, Enlistment.Done()이 구현 인스턴스에서 호출 될 때까지는 롤백 할 수있는 기회가 여전히 있습니다! –

+0

내 대답은 당신이 찾고 있던 것이 아니 었나요? –

답변

0

대신 Transaction.Rollback(Exception ex)를 호출해야합니다 :`Commit`가 호출 된 후

public void Commit(Enlistment enlistment) 
    { 
     Transaction currentTx = Transaction.Current; 
     if (currentTx != null) 
     { 
     currentTx.RollBack(new Exception("I give up!"); 
     } 
    } 
+0

내 테스트 코드에 따라 Commit() 메서드를 호출 할 때 Transaction.Current가 항상 null 인 것으로 보입니다. 어떤 아이디어? – matori82