7 Replies Latest reply on Oct 24, 2006 1:57 AM by Weston M. Price

    Message Driven Beans reading messages before Application Sta

    Rocky Alam Newbie

      Hi,

      We are using the following:
      - JBoss AS 4.0.2
      - WebSphere MQ v5.3
      - IBM DB2 v8.1

      Description:
      Our app is using Message Driven Beans to receive messages from queues on WSMQ. The app is initialized by an external system communicating with our app via messaging using a queue dedicated for this process. The initialization includes loading all configuration files within the app. This process is mandatory for the app to function properly (obviously!).

      Problem:
      As soon as the app is deployed on to the application server, the MDBs start processing messages from all queues. This pretty much errors out all transactions within, and initially some messages are lost before app completes its startup process.

      Question:
      Is there a way to enable connections to specific queues while disabling the MDBs listening to other queues, and after the startup process is complete, bring all mdbs online programatically?

      Any help will be appreciated.
      Thanks

        • 1. Re: Message Driven Beans reading messages before Application
          hannwei Newbie

          I face a similar problem. Sometimes, there are still messages in a queue when JBoss is shutdown intentionally for maintenance. During the next startup of JBoss, before all the EJBs are successfully deployed, the previously-queued messages have already started to be processed by the MDBs. As the processing of those queued messages requires the EJBs that are still being deployed, there are lots of NameNotFound exceptions and transaction rollbacks during JBoss startup.

          Can JBoss be configured to start delivering queued messages to MDBs only after the complete startup of JBoss? This capability will help a lot by removing the tons of exceptions that are not supposed to happen.

          By the way, I am using jboss-4.0.4.GA-Patch1.

          Thanks.

          Hann Wei

          • 2. Re: Message Driven Beans reading messages before Application
            Elias Ross Master


            You can add to your MDB so they don't start too soon. Check out the DTD.

            • 3. Re: Message Driven Beans reading messages before Application
              hannwei Newbie

               

              "genman" wrote:

              You can add <depends> to your MDB so they don't start too soon. Check out the DTD.


              Thanks. Found the DeliveryActive tag in jboss_4_0.dtd.

              I added it with the value "false" to server/default/conf/standardjboss.xml:

               <invoker-proxy-binding>
               <name>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>
               <CreateJBossMQDestination>true</CreateJBossMQDestination>
               <!-- WARN: Don't set this to zero until a bug in the pooled executor is fixed -->
               <MinimumSize>1</MinimumSize>
               <MaximumSize>15</MaximumSize>
               <KeepAliveMillis>30000</KeepAliveMillis>
               <MaxMessages>1</MaxMessages>
               <MDBConfig>
               <ReconnectIntervalSec>10</ReconnectIntervalSec>
               <DeliveryActive>false</DeliveryActive>
               <DLQConfig>
               <DestinationQueue>queue/DLQ</DestinationQueue>
               <MaxTimesRedelivered>10</MaxTimesRedelivered>
               <TimeToLive>0</TimeToLive>
               </DLQConfig>
               </MDBConfig>
               </proxy-factory-config>
               </invoker-proxy-binding>
              


               <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>
               <CreateJBossMQDestination>true</CreateJBossMQDestination>
               <!-- WARN: Don't set this to zero until a bug in the pooled executor is fixed -->
               <MinimumSize>1</MinimumSize>
               <MaximumSize>1</MaximumSize>
               <KeepAliveMillis>30000</KeepAliveMillis>
               <MaxMessages>1</MaxMessages>
               <MDBConfig>
               <ReconnectIntervalSec>10</ReconnectIntervalSec>
               <DeliveryActive>false</DeliveryActive>
               <DLQConfig>
               <DestinationQueue>queue/DLQ</DestinationQueue>
               <MaxTimesRedelivered>10</MaxTimesRedelivered>
               <TimeToLive>0</TimeToLive>
               </DLQConfig>
               </MDBConfig>
               </proxy-factory-config>
               </invoker-proxy-binding>
              


              However, after a restart of JBoss, when I looked at the JMX console through a browser, the StateString of MDBs is still "Started". The State value shown by the console is 3. I thought the "Started" value should appear only after I have pressed the Start() button on the browser.

              They are ejb3 MDBs. Did I configure the DeliveryActive value at the right place?


              • 5. Re: Message Driven Beans reading messages before Application
                hannwei Newbie

                 

                "genman" wrote:
                There should be a startDelivery and stopDelivery method someplace: http://docs.jboss.org/jbossas/getting_started/v4/html/mdb.html


                Is the description at that URL up-to-date? I clicked the link:

                jboss.j2ee
                 - ear=aps.ear,jar=aps-ejb.jar,name=LocalReplyMDB,service=EJB3
                


                Then I was shown:

                ...
                MBean Java Class: org.jboss.ejb3.ServiceDelegateWrapper
                ...
                
                List of MBean operations:
                void start()
                void create()
                void jbossInternalLifecycle()
                void stop()
                void destroy()
                


                There wasn't an operation named startDelivery(). I searched the JBoss source code, and found the operation is defined only in the class:

                http://fisheye.jboss.org/browse/JBoss/jboss/src/main/org/jboss/ejb/plugins/jms/JMSContainerInvoker.java?r=1.74

                Just to show that LocalReplyMDB above is an MDB:

                @MessageDriven
                 (activationConfig=
                 {
                 @ActivationConfigProperty(propertyName="destinationType",
                 propertyValue="javax.jms.Queue"),
                 @ActivationConfigProperty(propertyName="destination",
                 propertyValue="queue/aps/localReply")
                 }
                 )
                public class LocalReplyMDB
                 implements MessageListener
                {
                


                Does it mean org.jboss.ejb3.ServiceDelegateWrapper used by the JMX console has erroneously left out startDelivery() and stopDelivery() when dealing with MDBs?



                • 7. Re: Message Driven Beans reading messages before Application
                  Weston M. Price Master

                  Correct. These are features that are being carried over to the JMS/JCA adapter which is the default messaging provider for EJB3 after RC9.