7 Replies Latest reply on Oct 14, 2005 5:22 AM by bloodasp

    Message lost or are not pulled by MDB

    bloodasp

      Hi,

      I have a pool of MDBs listening to a queue. I bombard the queue with 1000 messages concurrently (I made an app that creates 1000 threads that each sends a JMS message to the queue all at the same time approximately). The messages in the queue are persisted in a MySQL database.

      As the onMessage() method of the MDB is triggered, I log that event to a file. I'm wondering why sometimes, I dont get 1000 logs which I expect and instead get logs less than 1000.

      There are times when a number of messages stay stuck on the queue even if there are active MDBs listening. I can say the MDBs are listening because when I send a JMS message, it gets processed, yet the previously stuck messages remain stucked.

      I suspect It has something to do with the memory. I tried to cut down the number of threads into half, so that's 500 concurrent messages sent to the queue and out of the 12 times I tested, only once did I not receive all 500. I lost about 48 messages, which neither was logged (pulled by MDB) nor exists in the queue.

      Another reason I suspect the memory is because I stripped down my onMessage() method. I simply logged into a file. I haven't lost any message even If there were 1000 threads that sent the jms messages concurrently.

      Here's my ejb-jar.xml

      <?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>RequestProcessor</description>
       <display-name>RequestProcessor</display-name>
       <enterprise-beans>
       <message-driven>
       <ejb-name>RequestProcessor</ejb-name>
       <ejb-class>com.mobilegroupinc.gospel.RequestProcessor</ejb-class>
       <transaction-type>Container</transaction-type>
       <message-selector></message-selector>
       <message-driven-destination>
       <destination-type>javax.jms.Queue</destination-type>
       </message-driven-destination>
       </message-driven>
       </enterprise-beans>
       <assembly-descriptor>
       <container-transaction>
       <method>
       <ejb-name>RequestProcessor</ejb-name>
       <method-name>onMessage</method-name>
       <method-params>
       <method-param>javax.jms.Message</method-param>
       </method-params>
       </method>
       <trans-attribute>Required</trans-attribute>
       </container-transaction>
       </assembly-descriptor>
      </ejb-jar>
      


      Here's my jboss.xml
      <?xml version="1.0"?>
      <jboss>
      
      <invoker-proxy-bindings>
       <invoker-proxy-binding>
       <name>mgi-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>
       <MinimumSize>1</MinimumSize>
       <MaximumSize>20</MaximumSize>
       <KeepAliveMillis>30000</KeepAliveMillis>
       <MaxMessages>1</MaxMessages>
       <MDBConfig>
       <ReconnectIntervalSec>10</ReconnectIntervalSec>
       <DLQConfig>
       <DestinationQueue>queue/DLQ</DestinationQueue>
       <MaxTimesRedelivered>10</MaxTimesRedelivered>
       <TimeToLive>0</TimeToLive>
       </DLQConfig>
       </MDBConfig>
       </proxy-factory-config>
       </invoker-proxy-binding>
      </invoker-proxy-bindings>
      
      <container-configuration>
       <container-name>MGI Message Driven Bean</container-name>
       <call-logging>false</call-logging>
       <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">org.jboss.ejb.plugins.CallValidationInterceptor</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">org.jboss.ejb.plugins.CallValidationInterceptor</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>
       <MinimumSize>1</MinimumSize>
       <MaximumSize>20</MaximumSize>
       <MaxMessages>1</MaxMessages>
       </container-pool-conf>
      </container-configuration>
      
      <enterprise-beans>
       <message-driven>
       <ejb-name>RequestProcessor</ejb-name>
       <configuration-bean>MGI Message Driven Bean</configuration-bean>
       <destination-jndi-name>queue/gospelQueue</destination-jndi-name>
       <invoker-bindings>
       <invoker>
       <invoker-proxy-binding-name>mgi-message-driven-bean</invoker-proxy-binding-name>
       </invoker>
       </invoker-bindings>
       <mdb-user>mdb</mdb-user>
       <mdb-passwd>mgimdb</mdb-passwd>
       <!--<resource-ref>
       <res-ref-name>java:/JVMILXAConnectionFactory</res-ref-name>
       <res-type>javax.jms.QueueConnectionFactory</res-type>
       <jndi-name>java:/JVMILXAConnectionFactory</jndi-name>
       </resource-ref>-->
       </message-driven>
      </enterprise-beans>
      </jboss>
      


      My threads are set to send the message with the following settings:
      priority=1
      timeout=30000ms

      My queue settings:
      redelivery=3
      redeliverywait=3000ms

      I'm on a development pc:
      P4 3.06GHz
      512RAM
      WinXP Home
      using JBoss 4.0.2, MySQL 4.1

      Is this a tweaking issue or a programming issue?
      How do I tweak JBoss so JMS will behave as expected?
      Any help is appreciated.

      Thank you very much.


        • 1. Re: Message lost or are not pulled by MDB

          Hi,

          I am also trying to use an mbean to send logging info to a mysql database. I cannot find any tutorials or demos showing me how to do this. Would you mind telling me where you learned how to do this, or point me to some sample code. It would be much appreciated!!

          Thank you

          • 2. Re: Message lost or are not pulled by MDB
            bloodasp

             

            "Dornus" wrote:
            Hi,

            I am also trying to use an mbean to send logging info to a mysql database. I cannot find any tutorials or demos showing me how to do this. Would you mind telling me where you learned how to do this, or point me to some sample code. It would be much appreciated!!

            Thank you


            You could use database logging via log4j or do it manually. In my case, I did it manually just to test but will port to log4j later on.

            • 3. Re: Message lost or are not pulled by MDB
              bloodasp

               

              "Dornus" wrote:
              Hi,

              I am also trying to use an mbean to send logging info to a mysql database. I cannot find any tutorials or demos showing me how to do this. Would you mind telling me where you learned how to do this, or point me to some sample code. It would be much appreciated!!

              Thank you


              Hi,

              Here's a link I found:
              http://www.onjava.com/pub/a/onjava/2002/08/07/log4j.html?page=3

              • 4. Re: Message lost or are not pulled by MDB

                Thanks for the link. I think that's a bit ahead of where I am at the moment. I am currently attempting to get a sar within an ear file to work correctly.

                Are you using ejb3? If so, do you mind sharing any relevant code you needed in your jboss-service.xml file? Also, did you need to create an interface for your MDB to get it to work?

                Thanks

                • 5. Re: Message lost or are not pulled by MDB

                  Nevermind, I figured out how to set up MDB using EJB3 annotations. I will add my logging code into it and do some tests similar to yours. If I do not experience the same results as you I'll let you know. Sorry for the temporary threadjack.

                  • 6. Re: Message lost or are not pulled by MDB

                    I have created a detailed tutorial/example for ejb3 logging. Maybe you can try it and see if it works better for you.
                    http://wiki.jboss.org/wiki/Wiki.jsp?page=UsingJMSAndMDBToLogToAMySqlDatabase

                    • 7. Re: Message lost or are not pulled by MDB
                      bloodasp

                      Hi Dornus,

                      Thanks for the tutorial. I haven't gone through the details of your tutorial but will later on. Right now, I just use log4j.

                      Anyway, I have tweaked the number of timetolive of the messages and no messages are lost (as far as I've tested), but there are times when I increase the volume of the messages to 10K that messages remain in the queue even if I have live MDBs. Will investigate further.

                      Thanks!