Results 1 to 6 of 6

Thread: Caching Connection?

  1. #1

    Question 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.

    Code:
    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.


    Code:
        <bean id="fat.fillRouter" class="com.xx.FillRouter">
    
            <constructor-arg value="fat.toSke"/>
    ...
        </bean>
    
        <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>
    
    	<bean id="common-ibmmq.queueConnectionFactory" class="com.ibm.mq.jms.MQConnectionFactory" lazy-init="true">
    		<property name="queueManager" value="${mq.conn.fac.name.mgr}" />
    		<property name="hostName" value="${mq.conn.fac.host}" />
    		<property name="port" value="${mq.conn.fac.port}" />
    		<property name="channel" value="${mq.conn.fac.channel}" />
    		<property name="transportType" value="1" />		
    	</bean>
    
    	<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" />
    	</bean>
    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. #2
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,840

    Default

    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. #3

    Default Perfect solution.

    Thanks. It is a perfect solution.

  4. #4

    Question 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. #5
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,840

    Default

    I think both of your questions are answered in the top-level javadoc:
    http://static.springsource.org/sprin...onFactory.html

    Let me know if you still require any clarification.

  6. #6

    Question Please suggest.

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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •