4 Replies Latest reply on Aug 9, 2012 3:29 AM by newway

    Why a message is not being redelivered

    newway

      Hi,

       

      I have an MDB that fails with the following errors:

       

       

      08/08/2012 07:29:06,859 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (Thread-14 (HornetQ-client-global-threads-19616316)) ORA-00060: deadlock detected while waiting for resource
      
      
      08/08/2012 07:29:07,859 ERROR [org.jboss.as.ejb3.tx.CMTTxInterceptor] (Thread-14 (HornetQ-client-global-threads-19616316)) javax.ejb.EJBTransactionRolledbackException: java.lang.RuntimeException: javax.persistence.PersistenceException: org.hibernate.exception.LockAcquisitionException: ORA-00060: deadlock detected while waiting for resource
      
      
      08/08/2012 07:29:07,859 ERROR [org.jboss.ejb3.invocation] (Thread-14 (HornetQ-client-global-threads-19616316)) JBAS014134: EJB Invocation failed on component CBMTaskEventsMDB for method public abstract void javax.jms.MessageListener.onMessage(javax.jms.Message): javax.ejb.EJBTransactionRolledbackException: java.lang.RuntimeException: javax.persistence.PersistenceException: org.hibernate.exception.LockAcquisitionException: ORA-00060: deadlock detected while waiting for resource
      
      
      
                at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleInCallerTx(CMTTxInterceptor.java:139) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:204) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:306) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
      ...
      
      

       

      I know that I need to handle the deadlocks problem - but the thing that I am curios about is why the message is not being redelivered - I see this error message only once, i don't see it in the DLQ - so where is it?

       

      (Running on JBOSS 7.1.1.Final)

      thanks,

      Noa

        • 1. Re: Why a message is not being redelivered
          newway

          same behavior also happens on jboss 4.2.3 with jboss messaging 1.4.5.GA - which probably points that the problem comes from my code - but i don't know where to start looking

          • 2. Re: Why a message is not being redelivered
            newway

            Found the problem.

             

            I have a base class that all the MDBs inherit from and one of the things it does is to wrap the onMessage method.

             

            the wrapping looked like this:

             

            try {
             process(message);
            } finally {
                   destinationHandlerContainer.disconnectDestinationHandlers();
            }
            

             

            the problem was that when an exception was thrown is would have been caught by the messaging indfra and than return the execute the finally block.

             

            so this fixes the problem:

             

            try {
             process(message);
            } catch (Throwable t) {
                   throw new RuntimeException(t);
            } finally {
                   destinationHandlerContainer.disconnectDestinationHandlers();
            }
            
            • 3. Re: Why a message is not being redelivered
              jbertram

              According to the JMS 1.1 specification (section 4.5.2) it isn't appropriate to throw a RuntimeException from onMessage():

              A client can register an object that implements the JMS MessageListener interface with a MessageConsumer. As messages arrive for the consumer, the provider delivers them by calling the listener’s onMessage method.

               

              It is possible for a listener to throw a RuntimeException; however, this is considered a client programming error. Well-behaved listeners should catch such exceptions and attempt to divert messages causing them to some form of application-specific 'unprocessable message' destination.

               

              Furthermore, a RuntimeException thrown from any method of the message-driven bean class (including a message listener method and the callbacks invoked by the container) results in the transition to the 'does not exist' state. This means that the instance of the MDB has to be thrown away by the container and another has to be created.

               

              At the end of the day you should just get the MessageDrivenContext and invoke setRollbackOnly() instead of throwing a RuntimeException.  That should force redelivery as expected.

              1 of 1 people found this helpful
              • 4. Re: Why a message is not being redelivered
                newway

                Thanks, I think you already explained that to me once before, hopefully I will not need this reminder in the future