2 Replies Latest reply on Aug 7, 2007 6:03 PM by jc7442

    EJB3 and Timeout.

    jc7442

      I try to set the timeout for only one EJB. I have chack the Wiki (http://wiki.jboss.org/wiki/Wiki.jsp?page=TransactionTimeout). When I change the timeout in the jboss-service.xml, it is ok. When I change the timeout in jboss.xml it is ignored.

      In my code, I have a MDB that invoke a session bean. So the jboss.xml is :

      <?xml version="1.0"?>
       <jboss>
      
       <enterprise-beans>
       <message-driven>
       <ejb-name>AuditExtractorMDB</ejb-name>
       <jndi-name>AuditExtractorMDB</jndi-name>
       <exception-on-rollback>true</exception-on-rollback>
       <method-attributes>
       <method>
       <method-name>*</method-name>
       <transaction-timeout>500</transaction-timeout>
       </method>
       </method-attributes>
       </message-driven>
       <session>
       <ejb-name>J2EEAuditExtractorImpl</ejb-name>
       <jndi-name>J2EEAuditExtractorImpl</jndi-name>
       <exception-on-rollback>true</exception-on-rollback>
       <method-attributes>
       <method>
       <method-name>*</method-name>
       <transaction-timeout>300</transaction-timeout>
       </method>
       </method-attributes>
       </session>
      
       </enterprise-beans>
      
       </jboss>


      That code is deployed in a ear and jboss.xml is in the META-INF directory.

      I do not want to add annotation is code (timeout has to be configured at deployment).

      Did someone succeed to change the tiemout for one EJB in jboss.xml. Samples and help are welcome.

        • 1. Re: EJB3 and Timeout.
          marcelkolsteren

          The timeout specified in jboss.xml is only used if the EJB3 container needs to create a new transaction when the method in the session bean is called. A new transaction is only created in the following two cases:

          - the transaction attribute is Required and there is no transaction running
          - the transaction attribute is RequiresNew

          The transaction attribute is Required by default, but can be overriden in the ejb-jar.xml (<container-transaction> element) or with the @TransactionAttribute annotation.

          In your application, probably a transaction is started with the default timeout when the MDB's onMessage method is invoked, and that same transaction is used by your session bean.

          • 2. Re: EJB3 and Timeout.
            jc7442

            In my case all transaction are required. Tra,saction is open by the container for the MDB but timeout for messagen driven seems not to be used.

            I move to bean managed transaction for my MDB and I set the timeout before beginning the transaction. It works fine and it solve another problem that I have, the message was redelivered when the MDB was in progress.