2 Replies Latest reply on Sep 11, 2006 9:27 PM by tnine

    Manually Acknowlegeing a message

    tnine

      Manually acknowledging a message Jboss 3.2.6

      Hi all,
      I?m trying to find some documentation on Jboss MQ message acknowledgement, but I can?t seem to find it anywhere. We have the following setup.

      Tomcat Web Servers (Server A)
      JBoss MQ Queue (Server B)
      JBoss MQ Remote Queue MDB (Server C)

      Our tomcat servers push the message on the queue on Server B. Server C has a remote proxy defined, and then receives the message and processes it. I want the MDB on JBoss server C to manually acknowledge the message. I?ve set acknowledge-mode to Dups-ok-acknowledge, but that really doesn?t solve my issue. I have the following flow in the on Receive code,


      ? delegate to POJO code?
      
       //if we get here id didn't blow up
       try {
       message.acknowledge();
       } catch (JMSException e) {
       throw new UndeclaredThrowableException(e);
       }
      

      As you can see I want to manually acknowledge the message only if the POJO delegation is successful, how can I accomplish this? Currently if the POJO code fails, the message is lost off of the queue on server B.

      Thanks,
      Todd


        • 1. Re: Manually Acknowlegeing a message
          genman

          Use container MDB transactions and MessageDrivenContext.setRollbackOnly() if the POJO work fails. Don't manually ack messages in your MDB, that's the container's responsibility.

          • 2. Re: Manually Acknowlegeing a message
            tnine

            Hi Genman,
            Thanks for the help, but that didn?t seem to work. The contain does not seem to be running a transaction. I have included by ejb-jar.xml and the exception stacktrace I receive. If I change my pojo code to cause itself to sleep for 2 minutes, I notice the message is already off of the queue on server B as soon as onMessage is invoked in my remote MDB. Is there some other configuration that I am missing?

            <?xml version="1.0" encoding="UTF-8"?>
            <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
            "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
            <ejb-jar>
             <description>Message Driven Bean</description>
             <display-name>CATS Message Driven Beans Configuration</display-name>
            
             <enterprise-beans>
            
             <message-driven>
             <description>
             Bean to access messages from cats queues
             </description>
             <display-name>CATSMessageAccess</display-name>
            
             <ejb-name>ejb/CATSMessageAccess</ejb-name>
            
             <ejb-class>
             com.ata.utilities.mdd.MessageAccessBean
             </ejb-class>
            
             <transaction-type>Container</transaction-type>
             <acknowledge-mode>Auto-acknowledge</acknowledge-mode>
            
             <message-driven-destination>
             <destination-type>javax.jms.Queue</destination-type>
             </message-driven-destination>
            
             </message-driven>
             </enterprise-beans>
            </ejb-jar>
            
            


            My Stacktrace

            21:10:02,765 INFO [STDOUT] 21:10:02,765 INFO [SessionFactoryImpl] closing
            21:10:02,765 ERROR [LogInterceptor] RuntimeException in method: public abstract void javax.jms.MessageListener.onMessage(javax.jms.Message)
            java.lang.IllegalStateException: getRollbackOnly must only be called in the context of a transaction (EJB 2.0 - 15.5.1)
             at org.jboss.ejb.MessageDrivenEnterpriseContext$MessageDrivenContextImpl.getRollbackOnly(MessageDrivenEnterpriseContext.java:192)
             at com.ata.utilities.mdd.MessageAccessBean.onMessage(MessageAccessBean.java:78)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:324)
             at org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke(MessageDrivenContainer.java:458)
             at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
             at org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor.invoke(MessageDrivenInstanceInterceptor.java:62)
             at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
             at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:282)
             at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:148)
             at org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke(RunAsSecurityInterceptor.java:90)
             at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
             at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
             at org.jboss.ejb.MessageDrivenContainer.internalInvoke(MessageDrivenContainer.java:372)
             at org.jboss.ejb.Container.invoke(Container.java:709)
             at org.jboss.ejb.plugins.jms.JMSContainerInvoker.invoke(JMSContainerInvoker.java:914)
             at org.jboss.ejb.plugins.jms.JMSContainerInvoker$MessageListenerImpl.onMessage(JMSContainerInvoker.java:1208)
             at org.jboss.jms.asf.StdServerSession.onMessage(StdServerSession.java:276)
             at org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessageConsumer.java:877)
             at org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:159)
             at org.jboss.mq.SpySession.run(SpySession.java:351)
             at org.jboss.jms.asf.StdServerSession.run0(StdServerSession.java:200)
             at org.jboss.jms.asf.StdServerSession.run(StdServerSession.java:180)
             at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:743)
             at java.lang.Thread.run(Thread.java:534)