13 Replies Latest reply on Nov 14, 2001 1:45 AM by jgunther

    Problem with message not removed from queue

    jgunther

      For some reason, whenever a message is received and processed from a queue it appears not to be marked as processed. If I shutdown JBoss and restart, the message within the queue gets re-consumed. Any ideas?

        • 1. Re: Problem with message not removed from queue

          Your messages is probably not properly acknowledge.

          Are you running your session as transacted withou doing a commit?

          (We also ha a bug a couple a month ago: if you resent a message it would not be acknowledged for the new destination, but that is at least fixed in CVS HEAD).

          //Peter

          • 2. Re: Problem with message not removed from queue
            jgunther

            No, the session is not set to be transacted. Here is the setup of the session and how the message is consumed:

            ...
            QueueConnectionFactory conFactory =(QueueConnectionFactory) ctx.lookup(CONNECTION_FACTORY);
            connection = conFactory.createQueueConnection();
            session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
            Queue queue = (Queue) ctx.lookup("queue/SomeQ");
            receiver = session.createReceiver(queue);
            connection.start();
            ...
            TextMessage msg = (TextMessage)message;
            String s = msg.getText();
            si.writeMsg(s);
            ...

            Any other ideas?

            • 3. Re: Problem with message not removed from queue
              charlesc

              Did you configure a datasource for JBossMQ? I am not sure which version of JBoss you are running. It might be useful if you can post your JBossMQ configuration.

              • 4. Re: Problem with message not removed from queue
                jgunther

                Yes, I did configure a datasource. The application is reading of the HL7QueueOut queue. I'm currently running 2.4.3. Below is my configuration. Thank you for all the assistance.

                <?xml version="1.0" encoding="UTF-8"?>
                <!-- This is where you can add and configure your MBeans
                ATTENTION: The order of the listing here is the same order as
                the MBeans are loaded. Therefore if a MBean depends on another
                MBean to be loaded and started it has to be listed after all
                the MBeans it depends on.
                -->


                <!-- ==================================================================== -->
                <!-- Classloading -->
                <!-- ==================================================================== -->

                8083
                <!-- Should resources and non-EJB classes be downloadable -->
                true


                <!-- ==================================================================== -->
                <!-- JNDI -->
                <!-- ==================================================================== -->

                1099




                <!-- ==================================================================== -->
                <!-- Transactions -->
                <!-- ==================================================================== -->

                300

                <!-- Use this attribute if you need to use a specific Xid
                implementation
                oracle.jdbc.xa.OracleXid
                -->


                <!-- Uncomment to use Tyrex (tyrex.exolab.org) transaction manager plugin
                instead of the org.jboss.tm.TransactionManagerService and comment out
                the TransactionManagerService above

                ../conf/default/domain.xml

                -->





                <!-- ==================================================================== -->
                <!-- Security -->
                <!-- ==================================================================== -->

                <!-- JAAS security manager and realm mapping -->

                org.jboss.security.plugins.JaasSecurityManager



                <!-- ==================================================================== -->
                <!-- JDBC -->
                <!-- ==================================================================== -->


                org.hsqldb.jdbcDriver



                1476
                true
                default
                false



                DefaultDS
                org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl

                jdbc:hsqldb:hsql://localhost:1476
                1200000
                sa
                10

                false
                false
                false
                true
                120000
                1800000
                false
                false
                1.0
                0


                <!-- ==================================================================== -->
                <!-- JBoss Server Management -->
                <!-- ==================================================================== -->

                5000


                <!-- ==================================================================== -->
                <!-- J2EE deployment -->
                <!-- ==================================================================== -->


                true
                false
                false
                true
                false


                <!-- Uncomment to add embedded tomcat service

                -->

                <!-- Uncomment and set file URL to add Jetty service (you can set config more than once)

                file URL to jetty.xml e.g. file:/usr/local/jboss/dist/conf/default/jetty.xml

                -->


                <!-- ==================================================================== -->
                <!-- JBossMQ -->
                <!-- ==================================================================== -->


                <!-- The StateManager is used to keep JMS perisitent state data. -->
                <!-- For example: what durable subscriptions are active. -->

                jbossmq-state.xml


                <!-- The PersistenceManager is used to store messages to disk. -->

                ../../db/jbossmq/


                <!-- InvocationLayers are the different transport methods that can be used to access the server -->

                java:/ConnectionFactory
                java:/XAConnectionFactory



                RMIConnectionFactory
                RMIXAConnectionFactory



                ConnectionFactory
                XAConnectionFactory



                UILConnectionFactory
                UILXAConnectionFactory


                <!-- The following three line create 3 topics named: testTopic, example, and bob -->
                <!--




                -->
                <!-- The following 9 line create 9 topics named: testQueue, controlQueue, A, B, -->
                <!-- C, D, E, F, and ex -->
                <!--









                -->




                <!-- Used for backwards compatability with JBossMQ versions before 1.0.0 -->

                ConnectionFactory
                QueueConnectionFactory


                ConnectionFactory
                TopicConnectionFactory


                <!-- For Message Driven Beans -->

                DefaultJMSProvider
                org.jboss.jms.jndi.JBossMQProvider
                java:/XAConnectionFactory
                java:/XAConnectionFactory


                StdJMSPool
                org.jboss.jms.asf.StdServerSessionPoolFactory



                <!-- Make sure you change EmbeddedTomcat to Jetty if you are using Jetty -->

                Default
                :service=ContainerFactory
                :service=EmbeddedTomcat


                <!-- Uncomment this and disable previous J2eeDeployer entry to enable an alternative "scoped" deployment

                Default
                :service=ContainerFactory
                :service=EmbeddedTomcat

                -->

                <!-- ==================================================================== -->
                <!-- JBossCX setup, for J2EE connector architecture support -->
                <!-- ==================================================================== -->




                <!-- Minerva no transaction connection manager factory.

                Use this for resource adapters that don't support
                transactions. -->

                MinervaNoTransCMFactory

                org.jboss.pool.connector.jboss.MinervaNoTransCMFactory




                <!-- Minerva local transaction connection manager factory.

                Use this for resource adapters that support "local"
                transactions. -->

                MinervaSharedLocalCMFactory

                org.jboss.pool.connector.jboss.MinervaSharedLocalCMFactory




                <!-- Minerva XA transaction connection manager factory

                Use this for resource adapters that support "xa"
                transactions. -->

                MinervaXACMFactory

                org.jboss.pool.connector.jboss.MinervaXACMFactory




                <!-- Connection factory for the Minerva JDBC resource adapter. This
                points at the same database as DefaultDS. -->

                MinervaDS
                JCA:service=RARDeployer

                Minerva JDBC LocalTransaction ResourceAdapter


                ConnectionURL=jdbc:HypersonicSQL:hsql://localhost:1476



                MinervaSharedLocalCMFactory

                <!-- See the documentation for the specific connection manager
                implementation you are using for the properties you can set -->

                # Pool type - uncomment to force, otherwise it is the default
                #PoolConfiguration=per-factory

                # Connection pooling properties - see
                # org.jboss.pool.PoolParameters
                MinSize=0
                MaxSize=10
                Blocking=true
                GCEnabled=false
                IdleTimeoutEnabled=false
                InvalidateOnError=false
                TrackLastUsed=false
                GCIntervalMillis=120000
                GCMinIdleMillis=1200000
                IdleTimeoutMillis=1800000
                MaxIdleTimeoutPercent=1.0


                <!-- Principal mapping configuration -->

                org.jboss.resource.security.ManyToOnePrincipalMapping


                userName=sa
                password=



                <!-- This is an example of using a resource adapter that supports XA
                transactions. The Minerva XA resource adapter requires an
                XADataSource to be in JNDI somewhere. JBoss doesn't include a
                database with an XA-compliant JDBC driver, so this will need to
                be configured to use whatever XADataSource implementation you
                have.


                MinervaXADS

                Put your XADataSource implementation class here





                XAMinervaDS
                JCA:service=RARDeployer

                Minerva JDBA XA Resource Adapter


                XADataSourceName=java:/MinervaXADS



                MinervaXACMFactory


                # Pool type - uncomment to force, otherwise it is the default
                #PoolConfiguration=per-factory

                # Connection pooling properties - see
                # org.jboss.pool.PoolParameters
                MinSize=0
                MaxSize=10
                Blocking=true
                GCEnabled=false
                IdleTimeoutEnabled=false
                InvalidateOnError=false
                TrackLastUsed=false
                GCIntervalMillis=120000
                GCMinIdleMillis=1200000
                IdleTimeoutMillis=1800000
                MaxIdleTimeoutPercent=1.0



                org.jboss.resource.security.ManyToOnePrincipalMapping


                userName=sa
                password=


                -->

                <!-- JMS XA Resource adapter, use this to get transacted JMS in beans -->

                JmsXA
                JCA:service=RARDeployer
                JMS Adapter
                MinervaXACMFactory
                <!-- See the documentation for the specific connection manager
                implementation you are using for the properties you can set -->

                # Pool type - uncomment to force, otherwise it is the default
                #PoolConfiguration=per-factory

                # Connection pooling properties - see
                # org.jboss.pool.PoolParameters
                MinSize=0
                MaxSize=10
                Blocking=true
                GCEnabled=false
                IdleTimeoutEnabled=false
                InvalidateOnError=false
                TrackLastUsed=false
                GCIntervalMillis=120000
                GCMinIdleMillis=1200000
                IdleTimeoutMillis=1800000
                MaxIdleTimeoutPercent=1.0


                <!-- Principal mapping configuration -->
                org.jboss.resource.security.ManyToOnePrincipalMapping




                <!-- ==================================================================== -->
                <!-- Auto deployment -->
                <!-- ==================================================================== -->


                J2EE:service=J2eeDeployer;
                JCA:service=RARDeployer

                ../deploy,../deploy/lib


                <!-- ==================================================================== -->
                <!-- JMX adaptors -->
                <!-- ==================================================================== -->






                10

                8082


                <!-- ==================================================================== -->
                <!-- Mail Connection Factory -->
                <!-- ==================================================================== -->

                Mail
                mail.properties
                user_id
                password


                <!-- ==================================================================== -->
                <!-- Uncomment to enable JMX monitoring of the bean cache

                -->
                <!-- ==================================================================== -->

                <!-- ==================================================================== -->
                <!-- Scheduler Service -->
                <!-- ==================================================================== -->
                <!-- Uncomment this to enable Scheduling - ->











                <!- - -->



                • 5. Re: Problem with message not removed from queue
                  charlesc

                  The lines:

                  <!-- The PersistenceManager is used to store messages to disk. -->

                  ../../db/jbossmq/


                  Indicates that you're using the rollinglogged PM. Unfortunately, I don't have any experience with that PM. I would try to empty that directory ../../db/jbossmq and retry... If performance is not a big issue, you can try the file-based PM too.

                  Sorry that I can't offer much more help,
                  Charles

                  • 6. Re: Problem with message not removed from queue
                    jgunther

                    Thank you for the feedback. Based on the feedback, I tried using the following configuration:

                    ...

                    ../../db/jbossmq/

                    ...

                    However, after the message is consumed, the message continues to remain in the queue and gets resent using the new configuration once I restart JBoss. Is there an attribute that keeps the message in the queue?

                    • 7. Re: Problem with message not removed from queue
                      charlesc

                      If everything works properly, the message that you sent to your queue will be persisted to a persistence store (depending on your PersistenceManager configuration).

                      If you are using the file-based PM, you should be able to see files (persisted messages) generated after you invoked send(). These files should be deleted once a Receiver successfully acknowledges the JBossMQ that it has received the message.

                      You should be able to monitor the changes in the directory ../../db/jbossmq as you send or receive messages.

                      If persistence message is NOT what you want, you can use DeliveryMode.NON_PERSISTENCE when you send your message. (Check JMS API javadoc) This by-passes the Persistence Manager altogether but your messages won't survive a server restart.

                      • 8. Re: Problem with message not removed from queue
                        jgunther

                        Currently, I'm using the file-based PM. Once the message is sent, a file does appear in a directory named after the queue. However, after the message is consumed by a MDB, the message is not deleted from the directory. Any ideas how I can turn on a trace?

                        Thank you for all your help.

                        • 9. Re: Problem with message not removed from queue

                          conf/default or conf/tomcat log4j.properties. Change INFO to DEBUG.

                          What are you doing in the MDB? Any rdbms access that perhaps rolls stuff back?

                          //Peter

                          • 10. Re: Problem with message not removed from queue
                            jgunther

                            No, I'm not doing any RDBMS calls. The MDB is very simple. Here is the code:

                            import java.util.*;
                            import javax.ejb.*;
                            import javax.jms.*;
                            import javax.naming.*;

                            public class SimpleMDB implements MessageDrivenBean, MessageListener
                            {
                            private static String QUEUE_NAME = "queue/HL7QueueOut";
                            private static String CONNECTION_FACTORY = "QueueConnectionFactory";
                            private static String PROVIDER_URL = "localhost";

                            private QueueConnectionFactory factory = null;
                            private QueueConnection connection = null;
                            private QueueSession session = null;
                            private QueueSender sender = null;
                            private Queue queue = null;

                            private MessageDrivenContext context;
                            private Context ctx;

                            public void ejbCreate()
                            {
                            try
                            {
                            //Context ctx = getInitialContext();

                            factory = (QueueConnectionFactory) ctx.lookup(CONNECTION_FACTORY);
                            connection = factory.createQueueConnection();
                            session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
                            queue = (Queue) ctx.lookup(QUEUE_NAME);
                            sender = session.createSender(queue);

                            System.out.println("SimpleMDB: ejbCreate called");

                            }catch(Exception e)
                            {
                            e.printStackTrace();
                            }

                            }

                            public void ejbRemove()
                            {
                            try
                            {
                            session.close();
                            System.out.println("SimpleMDB: ejbRemove called");

                            }catch(JMSException e)
                            {
                            e.printStackTrace();
                            }
                            }

                            public void setMessageDrivenContext(MessageDrivenContext context)
                            {
                            System.out.println("setMessageDrivenContext called");
                            this.context = context;
                            try
                            {
                            this.ctx = new InitialContext();

                            }catch(Exception e)
                            {
                            e.printStackTrace();
                            }
                            }

                            public void onMessage(Message message)
                            {
                            try
                            {
                            System.out.println("SimpleMDB: onMessage called");
                            TextMessage msg = (TextMessage) message;
                            sender.send(message);
                            System.out.println("SimpleMDB: message sent");

                            }catch(Exception e)
                            {
                            e.printStackTrace();
                            }

                            }

                            private Context getInitialContext() throws NamingException
                            {
                            Properties env = new Properties();
                            env.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
                            env.put("java.naming.provider.url", PROVIDER_URL);
                            env.put("java.naming.provider.url.pkgs", "org.jnp.interfaces");
                            return new InitialContext(env);
                            }

                            }

                            • 11. Re: Problem with message not removed from queue
                              charlesc

                              It appears that once your MDB receives a message (onMessage), you resend the message immediately (sender.send(message))... Could this be the problem?

                              • 12. Re: Problem with message not removed from queue

                                In my first reply I wrote this:

                                (We also ha a bug a couple a month ago: if you resent a message it would not be acknowledged for the new destination, but that is at least fixed in CVS
                                HEAD).

                                Which is exactly your problem. You are resending an already existing message, which will not work as far as I know in the current version of JBossMQ, only in the CVS one and perhaps in beta2.

                                Try copy your message and see if it works.

                                //Peter

                                • 13. Re: Problem with message not removed from queue
                                  jgunther

                                  That worked! Thank you for your assistance.