Announcement Announcement Module
No announcement yet.
jms producer performance with spring Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • jms producer performance with spring

    Hello, i created a simple producer consumer simulation based on spring, jms and activemq,
    i'm trying to reach high performance from both sides, producers and consumers,

    my setup is this :


    Connection settings :

    	<tx:annotation-driven />
    	<bean id="transactionManager" class="org.springframework.jms.connection.JmsTransactionManager">
    		 <property name="connectionFactory"  ref="connectionFactory" />
    	<amq:connectionFactory id="amqConnectionFactory" brokerURL="failover:(tcp://${broker.url}:61616)"  />
    	<bean id="connectionFactory"
    		<property name="targetConnectionFactory" ref="amqConnectionFactory" />
    	<amq:queue id="queue" physicalName="queue" />
    	<beans:bean id="jsonMessageConverter" class="XXXXX.converter.JsonMessageConverter" />
    Consumer settings :

    	<jms:listener-container concurrency="10"
    		acknowledge="auto" prefetch="1" message-converter="jsonMessageConverter" transaction-manager="transactionManager"
    		<jms:listener id="queueListener_1" destination="ooIntegrationQueue"
    			ref="myMessageListenerAdapter" />
    	<beans:bean id="myMessageListenerAdapter"
                class="org.springframework.jms.listener.adapter.MessageListenerAdapter" >
    		<beans:property name="delegate" ref="consumer"/>
        <beans:bean id="consumer" class="XXX.ConsumerImpl"/>
    Producer settings :

    	<beans:bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate"
    		p:connectionFactory-ref="connectionFactory" p:messageConverter-ref="jsonMessageConverter"
    		p:defaultDestination-ref="ooIntegrationQueue" p:sessionTransacted="true" />

    starting with the consumer, i managed to consume about 25 messages per second, which is extremely slow, i discovered the bottleneck to be the fact that i am using transactions,
    after googling for a bit, and playing with the configs, i found out that after autowiring the DefaultMessageListenerContainer and changing the cachelevel to
    listenerContainer.setCacheLevelName("CACHE_SESSION ") my performance increases to about 1500 messages per second while still having transactions.

    my problem is now with the producer which is still stuck at about 25 operations per sec,
    my producer test is simple :
            int numOfMessages = getNumberOfMessages();
            double startTime = System.currentTimeMillis();
    	for (int i = 1; i <= numOfMessages; i++) {
    		jmsTemplate.convertAndSend("HelloWorld" + i);
            double endTime = System.currentTimeMillis();
            double totalTime=(endTime-startTime)/1000;
            System.out.println("Time - "+totalTime+" seconds");
            System.out.println("EPS - "+numOfMessages/totalTime);
    i'm wondering how to reach similiar performances with the producer, since it now bottlenecks the consumers ?

    thanks !

  • #2
    Could you provide more insight into your test configuration?

    Is ActiveMQ using persistence? If so, what persistent mechanism is being leveraged?
    How many nodes/jvms are producing messages?
    How many nodes/jvms are consuming messages?



    • #3
      the messages aren't persistent, and in the above setup i made sure to test the consumer producer separately, so one jvm for producing, and later one jvm for consuming.

      the only way i manage to get decent producing results is if i overwrite the ApacheSession class and change it so it commits the transaction every X messages instead of the default which is every 1 message.

      i still wonder how come i manage to consume at such a rate and not produce without stuffing more messages into the transaction ?