Announcement Announcement Module
No announcement yet.
Caching Connection? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Caching Connection?

    We need the ability to cache the MQ Connection, because each time it is taking like 450 ms to get the Connection since the MQ server is in London and the code that is trying to get the connection is in Stamford. Please suggest.

    2010-06-08 15:04:24,700 INFO  [fat.fillsQueueContainer-1] fatprocessor.FillRouter - Time inside Router:0, 2010-06-08 15:04:24
    2010-06-08 15:04:25,156 INFO  [pool-2-thread-1] jms.FatTransferObjectMessageConverter - fat-processor:toMessage OrderID:US172316
    The FillRouter sends the message to the MQ Queue and it is taking 450ms to get the Connection.

        <bean id="fat.fillRouter" class="com.xx.FillRouter">
            <constructor-arg value="fat.toSke"/>
        <jms:outbound-channel-adapter id="fat.requestTopicSender"
                                      channel="fat.toSke" jms-template="fat.outboundRequestTopicJmsTemplate"/>
        <bean id="fat.outboundSkeJmsTemplate" parent="common-ibmmq.queueJmsTemplate" >
        		<property name="messageConverter" ref="fat.skeMessageConverter"/>
            	<property name="defaultDestination" ref="common.fatSendQueue"/>
    	<bean id="common-ibmmq.queueConnectionFactory" class="" lazy-init="true">
    		<property name="queueManager" value="${}" />
    		<property name="hostName" value="${}" />
    		<property name="port" value="${mq.conn.fac.port}" />
    		<property name="channel" value="${}" />
    		<property name="transportType" value="1" />		
    	<bean id="common-ibmmq.baseJmsTemplate" abstract="true"
    		class="org.springframework.jms.core.JmsTemplate" />
    	<bean id="common-ibmmq.queueJmsTemplate" parent="common-ibmmq.baseJmsTemplate" lazy-init="true">
    		<property name="connectionFactory" ref="common-ibmmq.queueConnectionFactory" />
    I need the ability to add something like
    <property name="cacheLevelName" value="CACHE_CONNECTION"></property>
    But, this property can be added only to DefaultMessageListenerContainer not the template. How can I achieve this? Please suggest.

  • #2
    You should be able to use Spring's CachingConnectionFactory and then your existing MQ connectionFactory would become the 'targetConnectionFactory' for the caching version.

    It's much more common, however, to rely on JNDI for resolution of the MQ ConnectionFactory instance. Is there a particular reason that you are defining it explicitly as a bean?


    • #3
      Perfect solution.

      Thanks. It is a perfect solution.


      • #4
        Just two more questions.

        1) What if the <property name="sessionCacheSize" value="10" /> and the connections reach 10. Does it get more Connections from the Server than 10 or does it wait for one process to release the connection? Please suggest.
        2) And also, when the java process is shutdown, does the CachingConnectionFactory release all the Connections it made from the server?


        • #5
          I think both of your questions are answered in the top-level javadoc:

          Let me know if you still require any clarification.


          • #6
            Please suggest.

            The link is helpful. Thanks.
            Last edited by srikanthradix; Jun 10th, 2010, 01:43 PM. Reason: Found the solution.