Hello,
The DMLC java doc 3.0.5.RELEASE says that cacheLevel can be set differently than CACHE_NONE in case of using transactions:
"This non-caching behavior can be overridden through the "cacheLevel" / "cacheLevelName" property, enforcing caching of the Connection (or also Session and MessageConsumer) even in case of an external transaction manager being involved. "
I am running the Spring JMS config as below [1] and configure the DMLC to use CACHE_CONSUMER and to be transacted, using the Spring JmsTransactionManager.
Using that config [1] I would assume that the JMS connection is getting cached by DMLC.
However while debugging I noticed that the JmsTransactionManager always calls into ConnectionFactory.createConnection() as part of the doBegin() implementation for the transaction.
Similarly the cleanup after a commit closes the connection again.
I do not see any JMS resource caching happening at the DMLC level when using the JmsTransactionManager.
Turning off transactions, correctly caches the connection, consumer and session.
Do I misunderstand the javadoc of DMLC or do I miss any further configuration in order to cache the JMS connection?
I am well aware that a CachingConnectionFactory is recommended when using the JmsTransactionManager in order to pool the connection at that level. Still I would like to understand if that javadoc is incorrect or if I can enable JMS resource caching at the DMLC level when using transactions.
Any feedback welcome.
Thanks,
Torsten Mielke
tmielke.blogspot.com
[1] Spring JMS config used
<bean id="jms" class="org.apache.activemq.camel.component.ActiveM QComponent">
<property name="configuration" ref="jmsConfigAmq" />
</bean>
<bean id="jmsConfigAmq" class="org.apache.activemq.camel.component.ActiveM QConfiguration" >
<property name="connectionFactory" ref="jmsPooledConnectionFactory" />
<property name="transacted" value="true"/>
<property name="transactionManager" ref="jmsTransactionManager" />
<property name="cacheLevelName" value="CACHE_CONSUMER"/>
</bean>
<bean id="jmsTransactionManager" class="org.springframework.jms.connection.JmsTrans actionManager">
<property name="connectionFactory" ref="jmsPooledConnectionFactory" />
</bean>
<bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFacto ry">
<property name="brokerURL" value="tcp://localhost:61617" />
<property name="watchTopicAdvisories" value="false" />
</bean>
<bean id="jmsPooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFa ctory" >
<property name="maxConnections" value="3"/>
<property name="connectionFactory" ref="jmsConnectionFactory"/>
</bean>
The DMLC java doc 3.0.5.RELEASE says that cacheLevel can be set differently than CACHE_NONE in case of using transactions:
"This non-caching behavior can be overridden through the "cacheLevel" / "cacheLevelName" property, enforcing caching of the Connection (or also Session and MessageConsumer) even in case of an external transaction manager being involved. "
I am running the Spring JMS config as below [1] and configure the DMLC to use CACHE_CONSUMER and to be transacted, using the Spring JmsTransactionManager.
Using that config [1] I would assume that the JMS connection is getting cached by DMLC.
However while debugging I noticed that the JmsTransactionManager always calls into ConnectionFactory.createConnection() as part of the doBegin() implementation for the transaction.
Similarly the cleanup after a commit closes the connection again.
I do not see any JMS resource caching happening at the DMLC level when using the JmsTransactionManager.
Turning off transactions, correctly caches the connection, consumer and session.
Do I misunderstand the javadoc of DMLC or do I miss any further configuration in order to cache the JMS connection?
I am well aware that a CachingConnectionFactory is recommended when using the JmsTransactionManager in order to pool the connection at that level. Still I would like to understand if that javadoc is incorrect or if I can enable JMS resource caching at the DMLC level when using transactions.
Any feedback welcome.
Thanks,
Torsten Mielke
tmielke.blogspot.com
[1] Spring JMS config used
<bean id="jms" class="org.apache.activemq.camel.component.ActiveM QComponent">
<property name="configuration" ref="jmsConfigAmq" />
</bean>
<bean id="jmsConfigAmq" class="org.apache.activemq.camel.component.ActiveM QConfiguration" >
<property name="connectionFactory" ref="jmsPooledConnectionFactory" />
<property name="transacted" value="true"/>
<property name="transactionManager" ref="jmsTransactionManager" />
<property name="cacheLevelName" value="CACHE_CONSUMER"/>
</bean>
<bean id="jmsTransactionManager" class="org.springframework.jms.connection.JmsTrans actionManager">
<property name="connectionFactory" ref="jmsPooledConnectionFactory" />
</bean>
<bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFacto ry">
<property name="brokerURL" value="tcp://localhost:61617" />
<property name="watchTopicAdvisories" value="false" />
</bean>
<bean id="jmsPooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFa ctory" >
<property name="maxConnections" value="3"/>
<property name="connectionFactory" ref="jmsConnectionFactory"/>
</bean>
Comment