1
votes

I used the Spring JMS cachingconnectionfactory to improve the performance of the my application based on Spring Integration and IBM MQ. I put sessioncachesize as 10 as we have the max of 10 concurrent threads working (ThreadPoolTaskExecutor) on consume/sending messages.

When I looked at the number of connections opened in MQ explorer (open output count for queue), it shows 10 and it stays on for days and never getting closed.

  1. Is there a way to programatically to detect connections which are potentially stale - say idle for half a day - I checked the resetConnection() but not sure how to get the last used time for the session.
  2. Does Spring provides any connection time out parameter for cacheconnection factory? or How to release these idle connections?

Also, the heartbeat/keepalive mechanism will not work for us as we want to physical close the cached connections based on last used time.

1
Something else must be going on; CachingConnectionFactory is a subclass of SingleConnectionFactory. There is only one connection from each factory; the sessions are cached within that connection.Gary Russell
The number output counts/connections in MQ explorer is the number of connection handles created by the IBM MQ classes. Per IBM documentation, A JMS Session object encapsulates an IBM MQ connection handle, which therefore defines the transnational scope of the session. Since the session cache size was 10 in my application, there were 10 MQ connections handles created (one for each session) stayed open for days and was inactive. Can we attach a session timeout to cachedsessions in CCF? ibm.com/support/knowledgecenter/en/SSFKSJ_9.0.0/…Selvakumar
My application requires a session timeout for cachedsessions in CCF. We would like to remove the sessions from cache and physical close if it is incactive/unused for a period of time. I am not sure if Spring provides option for attaching timeout to a session or exposing the last time session is used.Selvakumar

1 Answers

1
votes

If the timeout is a property of the Session object returned by IBM, you could subclass the connection factory, override createSession(); call super.createSession(...) then set the property before returning it.

You might also have to override getSession(...) and keep calling it until you a get a session that is not closed. I don't see any logic to check the session state in the standard factory. (getSession() calls createSession() when the cache is empty).