Martin
Martin

Reputation: 149

Expired sessions in GenericObjectPool

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

Upvotes: 1

Views: 1199

Answers (1)

Ravi Bhatt
Ravi Bhatt

Reputation: 3163

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.

Upvotes: 3

Related Questions