3 Replies Latest reply on Nov 18, 2003 2:17 PM by mikelarnett

    MessageDriven Bean Redelivery Fails

    mikelarnett

      Hi all,
      I am using JBoss3.2.1-Tomcat bundle.
      I am having some difficulty and expect that I am overlooking something obvious. I am trying to confirm that JMS messages that are not acknowledged get resent. I am using a MessageDrivenBean as the consumer. However, what I am seeing is that if I change the JDBC properties to an invalid login which causes the onMessage method to fail and therefore the acknowledgement is not sent back to the JMS Q. Send through a couple of messages, then reset the JDBC values to something valid, and never see the 'failed' messages again. How do you force the failed messages to be redelivered until acknowledged by the client?
      Thanks in advance,
      -MLA

      Here are the definitions for my Queue and EJB

      jbossmq-destinations:


      <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager


      jbossmq-service:

      <depends optional-attribute-name="Invoker">jboss.mq:service=Invoker
      com.promisant.QueueConnectionFactory
      com.promisant.QueueConnectionFactory
      18090
      60000
      true


      ejb.jar

      <message-driven >
      <![CDATA[]]>
      <display-name>Message Driven Request Test Bean</display-name>
      <ejb-name>ReportRequestMessageDrivenBean</ejb-name>
      <ejb-class>com.promisant.controller.modules.ReportRequestMessageDrivenBean</ejb-class>
      <transaction-type>Container</transaction-type>
      <acknowledge-mode>CLIENT_ACKNOWLEDGE</acknowledge-mode>
      <message-driven-destination>
      <destination-type>javax.jms.Queue</destination-type>
      <subscription-durability>NonDurable</subscription-durability>
      </message-driven-destination>
      </message-driven>




        • 1. Re: MessageDriven Bean Redelivery Fails
          mikelarnett

          Also, I never see the QueueDepth Change from 0 to 1...

          • 2. Re: MessageDriven Bean Redelivery Fails

            For the 256th factorial time!

            MDBs do not acknowledge messages
            (at least not directly).
            It is also an error to leak
            Exceptions from onMessage()

            onMessage is part of the JMS spec.
            If you want to the talk to the MDB use the
            MessageDrivenContext.

            You should configure your onMessage to run inside
            a transaction then code something like:

            MessageDrivenContext ctx;

            public void setMessageDrivenContext(MessageDrivenContext ctx)
            {
            this.ctx = ctx;
            }

            public void onMessage(Message m)
            {
            try
            {
            doSomething(m);
            }
            catch (ExpectedException e)
            {
            handleExpected(e);
            }
            catch (Throwable e)
            {
            log.warn("Error occurred", e);
            ctx.setRollbackOnly();
            }

            This is the only time I'm going to post this -
            this month :-)

            Regards,
            Adrian

            • 3. Belated thanks Adrian...
              mikelarnett

              It was helpful, even if it was recycled :)
              -MLA