0

From googling around, I know that if i use sessionTransacted=false DMLC will use acknowledgement modes (auto, client etc.) and If I use sessionTransacted=true, it will do session.commit after listener execution.

I am seeing a huge performance difference between the two modes. sessionTransacted=false is giving me lot of performance boost as compared to sessionTransacted=true. I am using non-persistent messaging and ActiveMQ as JMS provider. I am using spring DMLC for consuming messages.

As per this http://activemq.apache.org/should-i-use-transactions.html, there shouldn't be much difference as both session.commit and Message.acknowledge both are blocking calls.

Two Questions:

  1. Why is there a performance difference in these cases?
  2. Does both calls session.commit and Message.acknowledge blocks till ActiveMQ/JMS provider sends back a response? How does this work internally?

ConnectionFactory configuration:

    <!-- ActiveMQ connection factory to establish connection with broker.  -->
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
    <property name="brokerURL" value="${broker.url}"/>
</bean>

<!-- Wrap in a pool to avoid creating a connection per send. -->
<bean id="consumerJmsConnectionFactory"
    class="org.apache.activemq.pool.PooledConnectionFactory"
    destroy-method="stop">
    <property name="connectionFactory" ref="connectionFactory"/>
    <property name="maxConnections" value="6" /> <!-- Default is 1 ! -->
</bean>

The max connection count is 6 because I have other DMLC's using same pooled connection factory.

DMLC:

    <!-- Message listener container to receive messages from JshProxy. -->
<bean id="jshProxyListenerContainer"
    class="org.springframework.jms.listener.DefaultMessageListenerContainer"
    p:connectionFactory-ref="consumerJmsConnectionFactory"
    p:destination-ref="jshProxyPushTopic"
    p:pubSubDomain="true"
    p:subscriptionDurable="false"
    p:sessionTransacted="false"
    p:clientId="${cometd.jshProxyPush.clientId}"
    p:messageListener-ref="cometDActiveMQListener"/>

The DMLC is able to process messages fast after I made sessionTransacted to false. Which is what made me curious here.

xabhi
  • 798
  • 1
  • 13
  • 30
  • I don't have an answer for you but if you are not using transactions and you don't want message loss (in the event of a listener failure), you should use a SimpleMessageListenerContainer instead of the DMLC because the latter acks the message before the listener is invoked. – Gary Russell Feb 24 '15 at 14:10
  • As per http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/jms/listener/AbstractMessageListenerContainer.html, DMLC will also ack before the listener is invoked if i use auto_ack mode. – xabhi Feb 24 '15 at 14:30
  • Yes; that's what I said. The SMLC acks after the listener returns. – Gary Russell Feb 24 '15 at 14:44
  • Sorry for that I misread your comment. In my case tts okay if the messages are acknowledged before the listener invocation. As per this discussion http://stackoverflow.com/questions/28471833/dmlc-message-consumption-and-acknowledgement/28479031?noredirect=1#comment45299094_28479031, the receive() will not be called until listener execution is completed, so its okay. – xabhi Feb 24 '15 at 14:54
  • But, if your listener crashes or you lose power the message will be lost. – Gary Russell Feb 24 '15 at 14:57
  • Can you post up tour DMLC + ConnnectionFactory configuration? – Jakub Korab Feb 26 '15 at 15:28

0 Answers0