Announcement Announcement Module
Collapse
No announcement yet.
Performance issues with Spring & Jms:ActiveMQ Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Performance issues with Spring & Jms:ActiveMQ

    I am running some POC on Active MQ using spring configuration:
    I am encountering some serious performance issues:

    I am testing a point-to-point between two processes. client-server : client sending requests and server sending responses. One test uses spring configuration for both client and server and one is plain activemq code with no
    spring configuration. The POC which does not use Spring is twice as much faster as with Spring.

    Does any one have any idea why this might happen?

    I am using pooling as was suggested. Here is the configuration I am using for client and server:

    for client:

    <!-- Consumer -->
    <bean id="clientListener" class="example.Client">
    <property name="jmsTemplate" ref="jmsTemplate"/>
    <property name="adminQueue" ref="agentProcessQueue" />
    <property name="responseQueue" ref="destinationAgentQueue" />
    </bean>

    <bean id="containerClient"
    class="org.springframework.jms.listener.DefaultMes sageListenerContainer">
    <property name="concurrentConsumers" value="50"/><!-- change to 20 -->
    <property name="maxConcurrentConsumers" value="50"/>
    <property name="idleTaskExecutionLimit" value="10"/>
    <property name="maxMessagesPerTask" value="30"/>

    <!-- <property name="connectionFactory" ref="singleConnectionFactory" /> -->
    <property name="connectionFactory" ref="pooledConnectionFactory" />
    <property name="destination" ref="destinationAgentQueue" />
    <property name="messageListener" ref="clientListener" />
    </bean>


    <bean id="agentProcessQueue" class="org.apache.activemq.command.ActiveMQQueue">
    <constructor-arg value="agentProcessQueue"/>
    </bean>

    <bean id="destinationAgentQueue" class="org.apache.activemq.command.ActiveMQQueue">
    <constructor-arg value="destinationAgentQueue"/>
    </bean>

    <bean id="connectionFactory"
    class="org.apache.activemq.ActiveMQConnectionFacto ry">
    <property name="brokerURL" value="failovertcp://localhost:61616)?randomize=false" /> <!-- Single broker-->
    </bean>


    <bean id="singleConnectionFactory" class="org.springframework.jms.connection.SingleCo nnectionFactory">
    <property name="targetConnectionFactory"
    ref="connectionFactory" />
    <property name="reconnectOnException" value="true"/>
    </bean>

    <bean id="pooledConnectionFactory"
    class="org.apache.activemq.pool.PooledConnectionFa ctory">
    <constructor-arg ref="connectionFactory"/>
    <property name="maxConnections" value="5" />
    </bean>

    <!-- Producer -->
    <!-- for send response on temp q-->
    <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate" lazy-init="true">
    <property name="connectionFactory" ref="pooledConnectionFactory"/>
    </bean>


    and for server:

    <!-- Consumer -->
    <bean id="serverListener" class="example.Server">
    <property name="jmsTemplate" ref="jmsTemplate"/>
    </bean>

    <bean id="containerServer"
    class="org.springframework.jms.listener.DefaultMes sageListenerContainer">
    <property name="concurrentConsumers" value="50"/><!-- change to 20 -->
    <property name="maxConcurrentConsumers" value="50"/>
    <property name="idleTaskExecutionLimit" value="10"/>
    <property name="maxMessagesPerTask" value="30"/>

    <!-- <property name="connectionFactory" ref="singleConnectionFactory" /> -->
    <property name="connectionFactory" ref="pooledConnectionFactory" />
    <property name="destination" ref="agentProcessQueue" />
    <property name="messageListener" ref="serverListener" />
    </bean>


    <bean id="agentProcessQueue" class="org.apache.activemq.command.ActiveMQQueue">
    <constructor-arg value="agentProcessQueue"/>
    </bean>


    <bean id="connectionFactory"
    class="org.apache.activemq.ActiveMQConnectionFacto ry">
    <property name="brokerURL" value="vm://embeddedbroker?brokerConfig=xbean:activemq.xml" /> <!-- embedded broker -->
    </bean>

    <bean id="singleConnectionFactory" class="org.springframework.jms.connection.SingleCo nnectionFactory">
    <property name="targetConnectionFactory"
    ref="connectionFactory" />
    <property name="reconnectOnException" value="true"/>
    </bean>

    <bean id="pooledConnectionFactory"
    class="org.apache.activemq.pool.PooledConnectionFa ctory">
    <constructor-arg ref="connectionFactory"/>
    <property name="maxConnections" value="5" />
    </bean>

    <!-- Producer -->
    <!-- for send response on temp q-->
    <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate" lazy-init="true">
    <property name="connectionFactory" ref="pooledConnectionFactory"/>
    </bean>




    Thanks

  • #2
    Use the Spring CachingConnectionFactory instead of the SingleConnectionFactory; you don't need the pooling.

    Comment


    • #3
      This does not help. the Spring is still very slow compared to using no spring.
      This is the new configuration i use according to your recommendation:

      server:


      <!-- Consumer -->
      <bean id="serverListener" class="example.Server">
      <property name="jmsTemplate" ref="jmsTemplate"/>
      </bean>

      <bean id="containerServer"
      class="org.springframework.jms.listener.DefaultMes sageListenerContainer">
      <property name="concurrentConsumers" value="50"/><!-- change to 20 -->
      <property name="maxConcurrentConsumers" value="50"/>
      <property name="idleTaskExecutionLimit" value="10"/>
      <!-- <property name="maxMessagesPerTask" value="30"/> -->
      <property name="connectionFactory" ref="cachingConnectionFactory" />
      <property name="destination" ref="agentProcessQueue" />
      <property name="messageListener" ref="serverListener" />
      </bean>


      <bean id="agentProcessQueue" class="org.apache.activemq.command.ActiveMQQueue">
      <constructor-arg value="agentProcessQueue"/>
      </bean>


      <bean id="connectionFactory"
      class="org.apache.activemq.ActiveMQConnectionFacto ry">
      <property name="brokerURL" value="failovertcp://localhost:61616)?randomize=false" /> <!-- Single broker-->
      </bean>


      <bean id="cachingConnectionFactory"
      class="org.springframework.jms.connection.CachingC onnectionFactory">
      <constructor-arg ref="connectionFactory"/>
      <property name="sessionCacheSize" value="100" />
      </bean>


      <!-- Producer -->
      <!-- for send response on temp q-->
      <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate" lazy-init="true">
      <!-- <property name="connectionFactory" ref="pooledConnectionFactory"/>-->
      <property name="connectionFactory" ref="cachingConnectionFactory"/>
      </bean>


      client
      <!-- Consumer -->
      <bean id="clientListener" class="example.Client">
      <property name="jmsTemplate" ref="jmsTemplate"/>
      <property name="adminQueue" ref="agentProcessQueue" />
      <property name="responseQueue" ref="destinationAgentQueue" />
      <property name="sinkQueue" ref="sinkQueue" />
      </bean>

      <bean id="containerClient"
      class="org.springframework.jms.listener.DefaultMes sageListenerContainer">
      <property name="concurrentConsumers" value="50"/><!-- change to 20 -->
      <property name="maxConcurrentConsumers" value="50"/>
      <property name="idleTaskExecutionLimit" value="10"/>
      <!-- <property name="maxMessagesPerTask" value="30"/> -->
      <property name="connectionFactory" ref="cachingConnectionFactory" />
      <property name="destination" ref="destinationAgentQueue" />
      <property name="messageListener" ref="clientListener" />
      </bean>


      <bean id="agentProcessQueue" class="org.apache.activemq.command.ActiveMQQueue">
      <constructor-arg value="agentProcessQueue"/>
      </bean>

      <bean id="sinkQueue" class="org.apache.activemq.command.ActiveMQQueue">
      <constructor-arg value="sinkQueue"/>
      </bean>

      <bean id="destinationAgentQueue" class="org.apache.activemq.command.ActiveMQQueue">
      <constructor-arg value="destinationAgentQueue"/>
      </bean>

      <bean id="connectionFactory"
      class="org.apache.activemq.ActiveMQConnectionFacto ry">
      <property name="brokerURL" value="failovertcp://localhost:61616)?randomize=false" /> <!-- Single broker-->
      </bean>

      <bean id="cachingConnectionFactory"
      class="org.springframework.jms.connection.CachingC onnectionFactory">
      <constructor-arg ref="connectionFactory"/>
      <property name="sessionCacheSize" value="100" />
      </bean>


      <!-- Producer -->
      <!-- for send response on temp q-->
      <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate" lazy-init="true">
      <property name="connectionFactory" ref="cachingConnectionFactory"/>
      </bean>

      Comment

      Working...
      X