0

I am using child object of org.apache.commons.pool.impl.GenericObjectPool for providing connections to web services (child of org.apache.axis2.client.Stub).

How to setup the pool, so connections that have expired sessions will be automatically removed form pool? Method borrowConnection() must always return valid session.

Do I have to use some parameter in pool object, that will remove connection if expired or set some timeout for automatic deleting connections or are there any methods to check if session is expired on server side? As far as I know my web service does not provide cheap method for checking validity of session...

My code:

SDConnection sd
    = (SDConnection)connector.getConnectionManager().borrowConnection();

sd.someServiceMethod();

Calling someServiceMethod() is OK, but after some time of inactivity I get:

AxisFault: SID timed out

BartoszKP
  • 34,786
  • 15
  • 102
  • 130
Martin
  • 149
  • 1
  • 2
  • 7

1 Answers1

2

Did you look into validateObject method? you can put your conditions here and return a false to mark an object inside the pool as invalid.

Ravi Bhatt
  • 3,147
  • 19
  • 21
  • Now I override validateObject method of BasePoolableObjectFactory class. For testing session validity I use web service operation, that is by its developer marked as "cheap" and can be used for testing or keeping session alive. You have to set genericObjectPoolConnectionManager.setTestOnBorrow(true);. – Martin Nov 14 '11 at 13:05