PDA

View Full Version : Use single LDAP connexion



zikou
Sep 24th, 2007, 12:02 PM
Hi,
following my goal:
- My application should connect to an LDAP (using ldaptemplate), retreive data and then close connection. The retrieved data will reside in an ehcache instance.
Every Hour, the cache expire and my application will reconnect to the LDAP to retrieve the fresh datas.

I'm using the following configuration to feat to my need, I'm using a pool with 1 connection that expire after 10s of inactivity.
-Dcom.sun.jndi.ldap.connect.timeout=10000
-Dcom.sun.jndi.ldap.connect.pool=true
-Dcom.sun.jndi.ldap.connect.pool.maxsize=1


I thought that my config will ensure that the maximum number of connections will be 1. this was not the case.

Could you please tell me what's wrong with my approach and if there is another one to feet my objective ?

rasky
Sep 24th, 2007, 12:09 PM
For the details on pooling I'd have to refer you to the Java LDAP (http://java.sun.com/products/jndi/tutorial/ldap/connect/config.html) documentation. Spring LDAP does not touch the pooling issues at all, other than turning it on or off.

However, looking at your situation I don't see any use for pooling at all. I think you should turn off pooling completely, by setting the 'pooled' flag of your ContextSource to false.

zikou
Sep 24th, 2007, 02:59 PM
Thank you rasky for your prompt reply


For the details on pooling I'd have to refer you to the Java LDAP (http://java.sun.com/products/jndi/tutorial/ldap/connect/config.html) documentation. Spring LDAP does not touch the pooling issues at all, other than turning it on or off.
> I agree with you (I sow your other posts on pooling issues)


However, looking at your situation I don't see any use for pooling at all. I think you should turn off pooling completely, by setting the 'pooled' flag of your ContextSource to false.
I want to make dozens of requests using the same connection and then close asap the connection (this scenario will be reproduced each 1 hour, when the data cache expire).
since the ldaptemplate call DirContext.close() for each request, I want to ensure that it will not close the connection but turn it back to the pool.

I guess that turning off pooling will create a new connection for each operation.

could you please advice me how can I "properly" implement my use case using Spring Ldap ?

best regards,
Anis zouaoui