TransactionAttributeType.NOT_SUPPORTED的事务超时

时间:2013-05-29 09:20:04

标签: transactions ejb weblogic

我有一个通过互联网发送大量数据的J2EE应用程序(weblogic,oracle)。但是它会受到事务超时的影响。所以我按照以下方式重构了应用程序:

Timer具有容器管理的事务,但回调具有NOT_SUPPORTED标志。

@Stateless(mappedName = "TransferTimer", name = "TransferTimer")
public class TransferTimer implements ITransferTimerLocal {

    @Timeout
    @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
    public void timeoutCallback(final Timer timer) {
            vo = transferController.prepareTransfer();
            if (vo != null) {
                transferController.sendData(vo);
                transferController.finishTransfer(vo);
            }
..

使用bean管理的事务引入了新bean。长时间运行的方法根本不处理事务和数据库:

@Stateless
@TransactionManagement(value= TransactionManagementType.BEAN)
public class TransferController implements TransferControllerLocal {


    public TransferVO prepareTransfer() {
        TransferVO vo = null;
        try {
            userTransaction.begin();
..

    // no transactions must be there - it may take too much time
    public void sendData(TransferVO vo)  {
        client.sendFile(vo.getOrder(), vo.getArchive());
    }

虽然抛出了TransactionTimeout异常,但是client.sendFile()成功完成。

Caused by: weblogic.transaction.internal.TimedOutException: Transaction timed out after 61 seconds
BEA1-263D00276AD109CA0CA4
        at weblogic.transaction.internal.ServerTransactionImpl.wakeUp(ServerTransactionImpl.java:1788)
        at weblogic.transaction.internal.ServerTransactionManagerImpl.processTimedOutTransactions(ServerTransactionManagerImpl.java:1676)
        at weblogic.transaction.internal.TransactionManagerImpl.wakeUp(TransactionManagerImpl.java:1988)
        at weblogic.transaction.internal.ServerTransactionManagerImpl.wakeUp(ServerTransactionManagerImpl.java:1586)
        at weblogic.transaction.internal.WLSTimer.timerExpired(WLSTimer.java:35)

我不明白。为什么会失败?

0 个答案:

没有答案
相关问题