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:
- Why is there a performance difference in these cases?
- 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.