4 Replies Latest reply on Sep 2, 2009 3:07 AM by Andy Taylor

    Too Many Topics for a strict limit MDB

    Tarek Hammoud Novice

      Hello,

      The setup AS5.1 and HornetQ Beta 5.

      We have an MDB defined as such:

      @MessageDriven(name="TradeMDB", activationConfig ={
      @ActivationConfigProperty(propertyName ="destinationType",
       propertyValue="javax.jms.Topic"),
      @ActivationConfigProperty(propertyName ="Destination",
       propertyValue=EVENT_TOPIC_TRADE)
      },messageListenerInterface=MessageListener.class)
      @Pool(value = PoolDefaults.POOL_IMPLEMENTATION_STRICTMAX, maxSize = 1)
      
      public class TradeMDB implements MessageListener {
      


      What I have seen is the following:

      1) The JMX-Console is correctly reporting the limits set for the MDB. i.e (1 for everything)
      2) The org.hornetq in the JMX console is reporting way too many Trade topics being setup as if it is ignoring the limits setup.

      When we publish a message to the Trade Topic, the MDB (same instance) is being invoked many times completely ignoring the limits set. We have verified that one and only one message is being published.

      Too many destinations are being created for all of our MDB's even though we have proper limits on all of them.

      This is working correctly in JBM 1.4x. Thanks in advance for your help.

        • 1. Re: Too Many Topics for a strict limit MDB
          Andy Taylor Master

          Are you testing this on the same version of the application server. This is specific to MDB's not the messaging layer so i'm not sure if it is a HornetQ issue or not.

          Also could you provide a simple test i can run.

          • 2. Re: Too Many Topics for a strict limit MDB
            Tarek Hammoud Novice

            Yes I did use the same application server. I wrote a small test MDB to show the issue.

            package com.enfusion.ejbtest.mdb;
            
            import javax.ejb.ActivationConfigProperty;
            import javax.ejb.MessageDriven;
            import javax.jms.Message;
            import javax.jms.MessageListener;
            
            import org.jboss.ejb3.annotation.Pool;
            import org.jboss.ejb3.annotation.defaults.PoolDefaults;
            
            @MessageDriven(name="TestMDB", activationConfig ={
            @ActivationConfigProperty(propertyName ="destinationType",
             propertyValue="javax.jms.Topic"),
            @ActivationConfigProperty(propertyName ="Destination",
             propertyValue="topic/TestTopic")
            },messageListenerInterface=MessageListener.class)
            @Pool(value = PoolDefaults.POOL_IMPLEMENTATION_STRICTMAX, maxSize = 1)
            public class TestMDB implements MessageListener {
             public void onMessage(Message recvMsg) {
             }
            }
            



            application.xml
            <?xml version="1.0" encoding="UTF-8"?>
            
            <application xmlns="http://java.sun.com/xml/ns/javaee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd"
             version="5">
            
             <display-name>Test</display-name>
            
             <module>
             <ejb>TestEJB.jar</ejb>
             </module>
            </application>
            
            


            and build.xml

            <project default="dist" basedir=".">
            
             <property file="build.properties"/>
            
             <property name="src" location="src"/>
             <property name="build" location="build"/>
             <property name="classes" location="${build}/classes"/>
             <property name="lib" location="${build}/lib"/>
             <property name="dist" location="${build}/dist"/>
            
             <property name="jbosshome" location="/relmgt/thirdparty/jboss/jboss-5.1.0.GA"/>
            
             <target name="init">
            
             <path id="project.class.path">
             <pathelement location="${jbosshome}/common/lib/jboss-javaee.jar"/>
             <pathelement location="${jbosshome}/common/lib/jboss-ejb3-core.jar"/>
             <pathelement location="${jbosshome}/common/lib/jboss-ejb3-ext-api.jar"/>
             </path>
            
             <fileset id="ear.supportlibraries.fileset" dir="${jbosshome}">
             </fileset>
            
             <fileset dir="${classes}">
             <include name="com/enfusion/**"/>
             <include name="META-INF/**"/>
             </fileset>
            
             <!-- Create the build directory structure used by compile -->
             <mkdir dir="${build}"/>
             <mkdir dir="${build}/earsupportlibs"/>
             <mkdir dir="${build}/src"/>
             <mkdir dir="${build}/dist"/>
             <mkdir dir="${build}/dist/lib"/>
             <mkdir dir="${build}/dist/bin"/>
             <mkdir dir="${classes}"/>
             <mkdir dir="${lib}"/>
             </target>
            
             <target name="dependency" />
            
             <target name="compile" depends="init" description="compile the source " >
             <javac destdir="${classes}"
             debug="true"
             classpathref="project.class.path">
             <src path="${src}"/>
             <src path="${build}/src"/>
             </javac>
             </target>
            
             <target name="jar" depends="compile" >
            
             <manifest file="${build}/ejbmanifest.mf">
             <attribute name="Class-Path" value="${classpath}"/>
             </manifest>
            
             <!-- The ejb file -->
             <jar jarfile="${lib}/TestEJB.jar" manifest="${build}/ejbmanifest.mf">
             <fileset dir="${classes}">
             <include name="com/enfusion/**"/>
             <include name="META-INF/**"/>
             </fileset>
             </jar>
            
             <!-- The ear file -->
             <ear earfile="${lib}/Test.ear" appxml="etc/application.xml" update="true">
             <fileset dir="${lib}" includes="*EJB.jar"/>
             </ear>
             </target>
            
             <target name="dist" depends="jar">
             <copy todir="${dist}/lib">
             <fileset dir="${lib}/" includes="*.ear"/>
             <mapper type="flatten" />
             </copy>
             </target>
            
             <target name="clean">
             <delete dir="build"/>
             </target>
            
            </project>
            
            



            After deploying the ear, you can look under org.hornetq in the JMX console and see the excessive number of duplicate topics being created.

            Thanks for your help.

            • 3. Re: Too Many Topics for a strict limit MDB
              Tarek Hammoud Novice

              The code in the resource adapter is using maxSessions it seems. When I specified the config property maxSessions=1, it seems to only create one MDB session. I don't know if this is the right thing to do.

              • 4. Re: Too Many Topics for a strict limit MDB
                Andy Taylor Master

                The following code in your MDB:

                @Pool(value = PoolDefaults.POOL_IMPLEMENTATION_STRICTMAX, maxSize = 1)
                


                specifies the number of MDB instances in your MDB pool. When the onMessage method is requested from the JCA layer this will block until an instance from the pool becomes available.

                The maxSession controls how many handlers(sessions/consumers) in the JCA layer will call the MDB instances. By default it will be 15 and for each handler a subscription will be created. setting this to one ensures that only 1 subscription per MDB pool is used.

                Hope that makes sense!