Announcement Announcement Module
Collapse
No announcement yet.
Transaction Management and starvation... Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Transaction Management and starvation...

    Hi at all,

    In my application (batch application) a have used a transaction management.

    In particular I have a class in witch a method that call another method (belonging to other class, DAO class). This called method (in DAO class) is annotated with @Transactional(propagation = Propagation.REQUIRES_NEW) tag.

    The problem is: when I run the code locally, on my pc, all goes correctly, but when I run the code on the server, inside a ApplicationServer SunOne 9.1, during the third test (always in the third test), the execution stops exactly during the calling of the DAO method.

    To resolve this issue I have tried to annotate the caller method with @Transactional tag. With this artifice the test goes correctly also in the server. But obviously I don't want to annotate also the caller method.

    Someone of us can help me to resolve this situation?

    Thanks.

  • #2
    Post some code please.

    Comment


    • #3
      Ok, this is the code.....

      This is the DAO code:

      @Transactional(propagation = Propagation.REQUIRES_NEW)
      public void updateTransaction(String status, String transactionId) {

      TbTraTransactionCl transaction = (TbTraTransactionCl) ((HibernateTemplate) getPersistenceTemplate(PersistenceType.hibernateMo nitor))
      .get(TbTraTransactionCl.class, transactionId);

      Assert.isNotNull(transaction, "Transaction " + transactionId + " does not exist");

      transaction.setTraStrStatus(status);

      ((HibernateTemplate) getPersistenceTemplate(PersistenceType.hibernateMo nitor)).saveOrUpdate(transaction);
      }

      Comment


      • #4
        Again, sorry for not correctly submit

        Originally posted by samuele.pretini View Post
        This is the DAO code:

        @Transactional(propagation = Propagation.REQUIRES_NEW)
        public void updateTransaction(String status, String transactionId) {

        TbTraTransactionCl transaction = (TbTraTransactionCl) ((HibernateTemplate) getPersistenceTemplate(PersistenceType.hibernateMo nitor))
        .get(TbTraTransactionCl.class, transactionId);

        Assert.isNotNull(transaction, "Transaction " + transactionId + " does not exist");

        transaction.setTraStrStatus(status);

        ((HibernateTemplate) getPersistenceTemplate(PersistenceType.hibernateMo nitor)).saveOrUpdate(transaction);
        }
        This is the Caller code:
        public void doExecution(Forward forward) throws StateActionException { transactionDao.updateTransaction(forward.getCurren tState(), forward.getTransactionId());
        .....
        .....
        .....}

        This is the Bean declaration snippet for transaction management:

        <tx:annotation-driven transaction-manager="transactionManager"/>
        <bean id="transactionManager" class="org.springframework.orm.hibernate3.Hibernat eTransactionManager">
        <property name="sessionFactory" ref="hibernateMonitorSF"/>
        </bean>



        -----------------------------------------

        The transaction is used correctly, I have verified also the rollback and commit behavior.

        -----------------------------------------

        In I annotate with @Transactional tag the doExecution method all run correctly. Instead if a annotate the updateTransaction method with tag
        @Transactional(propagation = Propagation.NOT_SUPPORTED), all seems work fine.


        Thanks a lot for your help.

        Comment


        • #5
          Again the same problem.....

          Hi,

          as I have told in the past days, I have used Propagation.NOT_SUPPORTED settings.

          But When I have deleted the @Transactionale tag from the callers class, I have seen again a starvation problem. The execution stops in the caller code, exactly during the call to the "public void updateTransaction(String status, String transactionId)" method.

          Someone of us, can tell me the reason of this behaviour?

          Thanks.

          Comment


          • #6
            Hi.
            Have you found a solution?
            Iīm experiencing a similar problem.

            If I test a code with an embedded call to a method marked as PROPAGATION_REQUIRES_NEW with JUnit, everything works fine.
            If I call the same method from a scheduler (based on Spring and Quartz), the code blocks at the call of the method marked as PROPAGATION_REQUIRES_NEW. After changing the transaction method to PROPAGATION_REQUIRED it works. But thatīs not what I want...

            Thanks.

            Comment


            • #7
              So. Finally I found the problem.
              It was the used connection pool. For the scheduler application I configured only 1 connection. So the new transaction couldnīt get a new db connection...
              After increasing the connection pool all works find :-)

              Comment

              Working...
              X