8 Replies Latest reply on Jun 8, 2004 8:41 AM by cvandyck

    How to retrieve yet-to-be-processed messages from Queue?

    cvandyck

      I'm using JBoss 3.2.3.

      I've got a queue that I've defined as such:

       <mbean code="org.jboss.mq.server.jmx.Queue" name="jboss.mq.destination:service=Queue,name=CXMLPublishQueue">
       <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
       </mbean>
      


      And a Singleton MDB that consumes those messages with container configuration:

       <container-configuration>
       <container-name>Singleton Message Driven Bean</container-name>
       <call-logging>false</call-logging>
       <invoker-proxy-binding-name>singleton-message-driven-bean</invoker-proxy-binding-name>
       <container-interceptors>
       <interceptor>org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor</interceptor>
       <interceptor>org.jboss.ejb.plugins.LogInterceptor</interceptor>
       <interceptor>org.jboss.ejb.plugins.RunAsSecurityInterceptor</interceptor>
       <!-- CMT -->
       <interceptor transaction="Container">org.jboss.ejb.plugins.TxInterceptorCMT</interceptor>
       <interceptor transaction="Container" metricsEnabled="true">org.jboss.ejb.plugins.MetricsInterceptor</interceptor>
       <interceptor transaction="Container">org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor</interceptor>
       <!-- BMT -->
       <interceptor transaction="Bean">org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor</interceptor>
       <interceptor transaction="Bean">org.jboss.ejb.plugins.MessageDrivenTxInterceptorBMT</interceptor>
       <interceptor transaction="Bean" metricsEnabled="true">org.jboss.ejb.plugins.MetricsInterceptor</interceptor>
       <interceptor>org.jboss.resource.connectionmanager.CachedConnectionInterceptor</interceptor>
       </container-interceptors>
       <instance-pool>org.jboss.ejb.plugins.MessageDrivenInstancePool</instance-pool>
       <instance-cache></instance-cache>
       <persistence-manager></persistence-manager>
       <container-pool-conf>
       <MaximumSize>1</MaximumSize>
       <strictMaximumSize/>
       </container-pool-conf>
       </container-configuration>
      
      ...
      
      <invoker-proxy-bindings>
       <invoker-proxy-binding>
       <name>singleton-message-driven-bean</name>
       <invoker-mbean>default</invoker-mbean>
       <proxy-factory>org.jboss.ejb.plugins.jms.JMSContainerInvoker</proxy-factory>
       <proxy-factory-config>
       <JMSProviderAdapterJNDI>DefaultJMSProvider</JMSProviderAdapterJNDI>
       <ServerSessionPoolFactoryJNDI>StdJMSPool</ServerSessionPoolFactoryJNDI>
       <MaximumSize>1</MaximumSize>
       <MaxMessages>1</MaxMessages>
       <MDBConfig>
       <ReconnectIntervalSec>10</ReconnectIntervalSec>
       <DLQConfig>
       <DestinationQueue>queue/CXMLPublishQueue</DestinationQueue>
       <MaxTimesRedelivered>10</MaxTimesRedelivered>
       <TimeToLive>0</TimeToLive>
       </DLQConfig>
       </MDBConfig>
       </proxy-factory-config>
       </invoker-proxy-binding>
      </invoker-proxy-bindings>
      


      I've been trying to find a way to query my Queue and retrieve information about each of the Messages that have yet to be processed. I basically want to retrieve each actual message and query it.

      If anyone would be willing to point me in the right direction, I'd appreciate it greatly.

      thanks,
      Collin



        • 1. Re: How to retrieve yet-to-be-processed messages from Queue?
          cvandyck

          Just found the QueueBrowser... will take a look at that.

          • 2. Re: How to retrieve yet-to-be-processed messages from Queue?
            cvandyck

            I was able to use the QueueBrowser, but each time the Enumeration I asked of it would have no more elements.

            I read in another post that it would only list items that had been acknowledged -- does this mean that my MDB has to have the onMessage() invoked, or is there something I need to specify in my Queue deployment?

            • 3. Re: How to retrieve yet-to-be-processed messages from Queue?

              The QueueBrowser lists messages that have not yet been received by any client.

              • 4. Re: How to retrieve yet-to-be-processed messages from Queue?
                cvandyck

                 

                "adrian@jboss.org" wrote:
                The QueueBrowser lists messages that have not yet been received by any client.


                I guess I'm missing something here, then. Because my MDB is a singleton and it can only accept one message at a time, wouldn't that mean that if I had 10 messages queued up that I'd be able to see them using the QueueBrowser?

                Or, is the client not the MDB?

                Sorry if this is a simple answer; I'm relatively new to JMS.

                • 5. Re: How to retrieve yet-to-be-processed messages from Queue?
                  genman


                  Let's suppose you had 10 messages queued before your MDB started.

                  As soon as your MDB starts, you will have one less present, even before onMessage() is called. As soon as this message is accepted, another one is dequeued. This is the same for any other client.

                  • 6. Re: How to retrieve yet-to-be-processed messages from Queue?
                    cvandyck

                     

                    "genman" wrote:

                    Let's suppose you had 10 messages queued before your MDB started.

                    As soon as your MDB starts, you will have one less present, even before onMessage() is called. As soon as this message is accepted, another one is dequeued. This is the same for any other client.


                    Thanks for the info. That's strange, though, because I'm using my queue to manage the publishing of assets in my system. A publish may take a minute or more to complete. I basically put 10 publish messages into the queue, and over the course of 10 minutes, the MDB consumes each message, and moves to the next one.

                    Should I not, then, be able to see 9 messages in the queue during the first minute?



                    • 7. Re: How to retrieve yet-to-be-processed messages from Queue?

                      If you really are using that config, you would see 8 messages.
                      One is being processed and one is in the read-ahead.

                      My guess is that you either not using that config
                      or you are using a different queue.
                      e.g. JBoss's MDB creates a temporary queue if you don't specify the destination-jndi-name.

                      It is impossible to tell what it is doing, you have only posted some configuration with
                      no reference to your mdb config or any logging (either deployment or runtime).

                      • 8. Re: How to retrieve yet-to-be-processed messages from Queue?
                        cvandyck

                        In my jboss.xml:

                         <enterprise-beans>
                         ....
                        
                         <message-driven>
                         <ejb-name>PublishMessage</ejb-name>
                         <destination-jndi-name>queue/CXMLPublishQueue</destination-jndi-name>
                         <configuration-name>Singleton Message Driven Bean</configuration-name>
                         </message-driven>
                        
                         </enterprise-beans>
                        


                        And in my ejb-jar.xml:

                         <message-driven >
                         <description>[CDATA[]]</description>
                        
                         <ejb-name>PublishMessage</ejb-name>
                        
                         <ejb-class>com.company.PublishMessageBean</ejb-class>
                        
                         <transaction-type>Container</transaction-type>
                        
                         </message-driven>
                        


                        So I'd think that because I do specify this queue and container for my MDB that I should be able to see messages in the queue not yet processed.

                        Adrian, what other kind of logging could I do to help figure out why I can't see what is in the queue?

                        Here's the code I'm using to inspect the queue:

                         QueueBrowser browser = queueSession.createBrowser("queue/CXMLPublishQueue");
                         Enumeration enum = browser.getEnumeration();
                         while (enum.hasMoreElements())
                         {
                         Object object = enum.nextElement();
                         log.info("inspectPublishQueue: " + object);
                         }
                        


                        Which produces no output.

                        thanks,
                        Collin