开发者

Basic Spring Transaction Question - WebLogicJTATransactionManager/RequiresNew

I have AOP that intercepts a call to a method which starts a REQUIRED transaction. During the method logic, an exception is thrown. But the exception is caught so that a piece of data can be written out to a db via a new AOP pointcut on a different class/method which starts a RequiresNew. This RequiresNew should commit fine and once completed, it should rethrow the original exception causing the REQUIRED transaction to rollback. This doesn't seem to work though. Is that because even though the RequiresNew lives in its own transaction, if it lives within 开发者_如何学运维a REQUIRED transaction that rollsback...does that effect the RequiresNew transaction?

Thanks...jay


The second method is going to be a nested transaction with its own begin & end. It will be unaware of the first exception. Since you are anyway catching this exception why don't you throw it again?

Also why the need for a point cut for exception? Would it not be simple to raise an event/message which is handled asynchronously by lets say an ExceptionListener ?

The RequiresNew method will not know about the exception & would be a separate nested transaction. So ..

Requires Method

try {

...

} catch (Exception e) {

// Call method/point cut which has RequiresNew, this should go thru unless there are further exceptions inside the RequiresNew method.

throw new Exception("Transaction failed " );

}

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜