There is just one more thing I don't see clearly. I found quite contradicting
information about the use of pooled/cached connection factories.

First, at
http://tmielke.blogspot.com/2012/03/camel-jms-with-transactions-lessons.html
I found that it's recommended to use pooled connection factory with Camel
JMS and transactions.
"When using a camel-jms configuration as above, its really important to use
a pooled ConnectionFactory such as ActiveMQs PooledConnectionFactory or
Springs CachingConnectionFactory. Not using a pooled ConnectionFactory means
you will open a new JMS connection and session to the broker for every
transaction / message to be received."

>From this, it seems to be obvious that I must use CachingConnectionFactory
(as the broker I use is IBM/WebSphere MQ, I cannot use the
PooledConnectionFactory).

On the other hand, another source states that it isn't a good idea to use
CachingConnectionFactory for message listeners/consumers.
"It is generally not a good idea to use a caching connection factory with a
listener container, especially when using maxConcurrentConsumers >
concurrentConsumers - you can end up with cached consumers in the cache,
which get messages where there is no listener, and such messages can get
"stuck".
So, don't use a CCF in this case, it's really intended for use on the
producer side."
http://stackoverflow.com/questions/18863057/closing-session-when-using-springs-cachingconnectionfactory

Besides, another forum post recommends using WMQ's internal pooling instead.
http://camel.465427.n5.nabble.com/New-JMS-connection-being-created-for-every-message-td5637735.html

So I'm rather mixed whether I should or shouldn't use
CachingConnectionFactory. Can you give any direction?

My configuration so far is as follows:
<endpoint id="inboundMQMessages" uri="inboundMQ:queue:${queueName}"/>

<bean:bean id="inboundMQ"
class="org.apache.camel.component.jms.JmsComponent">
        <bean:property name="connectionFactory" ref="mqConnectionFactory"/>
        <bean:property name="transacted" value="true"/>
        <bean:property name="transactionManager" ref="jmsTxManager"/>
        <bean:property name="cacheLevelName" value="CACHE_CONSUMER"/>
        <bean:property name="concurrentConsumers" value="10"/>
        <bean:property name="maxConcurrentConsumers" value="20"/>
</bean:bean>
        
<bean:bean id="requiredJmsTx"
class="org.apache.camel.spring.spi.SpringTransactionPolicy">
        <bean:property name="transactionManager" ref="jmsTxManager"/>
        <bean:property name="propagationBehaviorName"
value="PROPAGATION_REQUIRED"/>
</bean:bean>
        
<bean:bean id="jmsTxManager"
class="org.springframework.jms.connection.JmsTransactionManager">
        <bean:property name="connectionFactory" ref="mqConnectionFactory"/>
</bean:bean>

<bean:bean id="mqConnectionFactory"
class="com.ibm.mq.jms.MQQueueConnectionFactory">
        <bean:property name="transportType">
                <util:constant static-field="${mqTransportType}" />
        </bean:property>
        <bean:property name="hostName" value="${mqHostName}" />
        <bean:property name="port" value="${mqPort}" />
        <bean:property name="queueManager" value="${mqQueueManager}" />
        <bean:property name="channel" value="${mqSubscriberChannel}" />
        <bean:property name="useConnectionPooling" value="true" />
        <bean:property name="pollingInterval" value="${mqPollingInterval}" />
        <bean:property name="rescanInterval" value="${mqRescanInterval}" />
</bean:bean>





--
View this message in context: 
http://camel.465427.n5.nabble.com/Best-Efforts-1-PC-pattern-from-MQ-to-DB-tp5751757p5751879.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to