Announcement Announcement Module
Collapse
No announcement yet.
MDB vs MDP Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • MDB vs MDP

    Hi, folks!
    I am currently planning to substitute a Message Driven Bean with a Message Driven Pojo, aiming to lower the constrain of

    needing an EJBContainer in a J2EE web application. I therefore tryed to write two projects for testing the performance of both this solutions:

    concerning the MDB project I subclassed the AbstractJmsMessageDrivenBean and in the onMessage() method I simply invoked 2

    services, one for printing to the stdout the payload of the message and the other one to insert the payload and a timestamp in a db

    by means of a Dao. I delegated the transaction management to the container, declaring the onMessage method of the MDB as transactional in the ejb deployment descriptor.

    Concerning the MDP, I implemented the MessageListener interface, and, according to the MDB onMessage() method I actually

    invoked again a Dao for writing the payload and a timestamp to a db and I simply outputted the payload to the console. In the

    spring-config file I configured the listenerContainer as stated below.

    [....]

    <bean id="listenerContainer" class="org.springframework.jms.listener.DefaultMes sageListenerContainer102">
    <property name="destination" ref="destination" />
    <property name="messageListener" ref="messageListener"/>
    <property name="connectionFactory" ref="singleConnectionFactory"/>
    <property name="transactionManager" ref="transactionManager"/>
    <property name="concurrentConsumers" value="5"/>
    </bean>

    <bean id ="singleConnectionFactory" class="org.springframework.jms.connection.SingleCo nnectionFactory102">
    <property name="targetConnectionFactory" ref="jmsQueueConnectionFactory"/>
    </bean>

    <bean id="wsjtm" class="org.springframework.transaction.jta.WebSphe reTransactionManagerFactoryBean"/>

    <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTran sactionManager">
    <property name="transactionManager" ref="wsjtm"/>
    </bean>

    [....]


    I set up the test envirorment and I performed some testings, varying from 1 to 10 the number of concurrentConsumer on the MDP implementation and accordingly

    the number of JMS Sessions in the MDB ListenerPort for the MDB implementation. As far as I could see, the MDB is

    always the better-performing-one. I also saw that raising the number of concurrentConsumers causes the gap between the two

    solutions to lower. However, the MDP solution never reaches the MDB one in terms of performances. Is there

    anything I can try to improve the MDP solution? Any advice is welcome.

    Best Regards.
    Alessio

  • #2
    As I understand SingleConnectionFactory is intended mostly for testing purposes. So I would recommend passing in the "real" ConnectionFactory to achieve comparable results.

    Regards,
    Andreas

    Comment


    • #3
      I do agree on the testing-purpose of the SingleConnectionFactory, actually it has been my second chance, since I started with the DefaultMessageListenerContainer102. The drawback of DefaultMessageListenerContainer is that as far as I understood it does no connection pooling, and I need it! I explain: using the DefaultContainer I kept on getting a lot of output strings on the console stating that no container managed alias was found. I guess it happens because it open a connection everytime it needs to get a message, instead of pooling the resources. I also tryed the powerful container, ServerSessionMessageListenerContainer, but I was not able to figure out how to configure it..is there any tutorial I could check out?
      Thanks
      Alessio

      Comment


      • #4
        As I understand, a single connection should be used by default (see API doc of AbstractMessageListenerContainer).
        The reason of the log message you mention I do not know, but to me it doesn't sound like being associated with connection pooling.

        Regards,
        Andreas

        Comment


        • #5
          I changed the singleConnectionFactory with a factory given by JNDI, as you can see on my new spring-config.xml below:

          [...]
          <bean id="jmsQueueConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryB ean">
          <property name="jndiName" value="jms/QM_alessio" />
          <property name="resourceRef" value="true" />
          </bean>

          <bean id="listenerContainer" class="org.springframework.jms.listener.DefaultMes sageListenerContainer102">
          <property name="destination" ref="destination" />
          <property name="messageListener" ref="messageListener"/>
          <!--<property name="connectionFactory" ref="singleConnectionFactory"/>-->
          <property name="transactionManager" ref="transactionManager"/>
          <property name="concurrentConsumers" value="5"/>
          <property name="connectionFactory" ref="jmsQueueConnectionFactory"/>
          </bean>
          [...]

          but it continues to be slower than the ejb, specially because of the following message I keep on getting printed on the console every second:

          W J2CA0114W: No container-managed authentication alias found for connection factory or datasource JMS$QM_alessio.

          I could certainly tighten the outputs changing the settings of Log4j, but it sounds to me like it is only a way to hid the problem, and not to solve it.
          Thanks
          Alessio.

          Comment


          • #6
            Originally posted by GenerRulez View Post
            W J2CA0114W: No container-managed authentication alias found for connection factory or datasource JMS$QM_alessio.

            I could certainly tighten the outputs changing the settings of Log4j, but it sounds to me like it is only a way to hid the problem, and not to solve it.
            I agree that changing the log level is not a solution. Though I must confess that I have no clue how to overcome that message as I have not used that part of the JMS support yet.

            Regards,
            Andreas

            Comment


            • #7
              Does your JMS provider support ServerSessionPool? If so you can use ServerSessionMessageListenerContainer.

              Comment


              • #8
                I tryed to use the SSMListenerCont but I failed in wiring it. Are you experienced in using? could you please send me your configuration xml?
                Thanks a lot
                Alessio

                Comment


                • #9
                  I haven't used it myself. I suggested it because the ServerSessionPool was likely to increase performance because of better resource pooling.

                  Comment

                  Working...
                  X