Using the Spring based JMS Endpoints in Servicemix

Posted by dave
on May 14, 2008 @ 05:07 PM

I've been running performance tests with Fuse ESB 3.3.1 and the spring based JMS endpoints over the last day or two.

One gotcha I've seen mentioned before with ActiveMQ is on the producer side you need to use a PooledConnectionFactory when using springs jmsTemplate. The same applies when using the Servicemix jms:provider endpoint (as its using jmsTemplate under the covers).

If your jms provider configuration looks similar to this:
1
2
3
4
5
6
7
8
9
10
11
 <jms:provider
      service="test:MySpringProviderService"
      endpoint="mySpringProvider"
      destinationName="queue/OUT"
      connectionFactory="#connectionFactory"
      pubSubDomain="false"
      stateless="false" />

 <bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
    <property name="brokerURL" value="tcp://localhost:61616" />
 </bean>

change the connectionFactory to something like this:

1
2
3
4
5
6
7
8
9
 <bean id="connectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory">
    <property name="connectionFactory">
      <bean class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL" value="tcp://localhost:61616" />
      </bean>
    </property>
    <property name="maxConnections" value="1" />
    <property name="maximumActive" value="1" />
  </bean>

Then by the numbers for my test flow (Jms Consumer->EIP->Bean->JMS Provider & processing/10K worth of messages) ...

Pooled ConnectionFactory:
     [java] Overall time: 40360 ms
     [java] Messages per sec: 247.77006937561944
     [java] 
     [java] Time: 41.064
     [java] 
     [java] OK (1 test)
     [java]    
Non-Pooled ConnectionFactory:
     [java] Overall time: 908363 ms
     [java] Messages per sec: 11.008814757976712
     [java] 
     [java] Time: 909.34
     [java] OK (1 test)
     [java] 
 

Those couple of lines of XML make a big difference. Without the pool, the JMS connection is torn down each time and that accounts for the disparity.

A second area to look out for is the jms:consumer endpoint configuration. Make sure you set the cacheLevel to CACHE_CONNECTION (1) or CACHE_CONSUMER (3). The default is CACHE_NONE. Below we set the cacheLevel for the underlying DefaultMessageListenerContainer to CACHE_CONSUMER

1
2
3
4
5
6
7
  <jms:consumer service="test:MySpringConsumerService"
        endpoint="mySpringConsumer"
        targetService="test:MySpringProviderService"
        destinationName="queue/SPRING_IN"
        connectionFactory="#connectionFactory"
        concurrentConsumers="1"
        cacheLevel="3"/>
I hope these two tips will help you fine tune your Servicemix performance.
Comments

Leave a response