1 Reply Latest reply on Dec 29, 2004 7:05 PM by Scott Stark

    Problem using UserTransaction timeout functionality.

    Mario Laubscher Newbie

      Hi
      I have a SessionBean which is dealing with a remote http-webservice. Sometime the webservie is down and I need to get a timeout within a reasonable time. Therefore I implemented in my SessionBean business method a own transaction handling via UserTransaction and the TransactionTimeout functionality. Unfortunately when the time out is reached the method throws no exception, it still tying to connect to the webservice.

      public Hashtable getArchiveItemList(String mandantId, Hashtable params, int responseSizeLimit) throws Exception {
       UserTransaction transaction = ejbContext.getUserTransaction();
      
       try{
       transaction.setTransactionTimeout(10);
       transaction.begin();
      
       // --> Web service connection code...
       // not showed...
      
       transaction.commit();
       }
       catch(Exception e){
       transaction.rollback();
       NovoPortalLog.error(this,"getDocumentList()",e);
       throw new Exception(e.getMessage());
       }
      }
      


      The 10 Sec. timeout works, I get the following WARN in the server.log
      15:15:39,702 WARN [TransactionImpl] Transaction TransactionImpl:XidImpl[FormatId=257, GlobalId=meilen/8, BranchQual=, localId=8] timed out. status=STATUS_ACTIVE
      


      About 4 minutes later I get than a exception from the Webservice.

      Q1) Should not a Exception be thrown when the UserTransaction timeout is reach?

      Q2) Is there any alternative to handle a transaction timeout?

      Many thanks!