Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
263 views
in Technique[技术] by (71.8m points)

java - LDAP connection pooling: can the context request its connection to be removed from the pool (and closed)?

I have a Java component deployed on a JBoss AS. It uses LDAP connection pooling to connect to an LDAP server backend (it creates javax.naming.directory.InitialDirContext with com.sun.jndi.ldap.connect.pool=true). Pooling works as expected, with the com.sun.jndi.ldap.connect.pool.timeout set to 5 sec: connection is closed by LDAP pool manager when idle for over 5 sec.

Is there a way for my LDAP context to request the connection to be forcefully closed and removed from the pool (or even the whole set of pool connections to be reset) ?

Reason for asking: when the LDAP server backend application is down but the host on which it runs is still healthy, my component LDAP search times out (ReadTimeout exception) and the context is closed. The connection is then returned to the pool manager. However the pool manager does not remove the connection from the pool: when the next context is created, the same connection will be used, producing another timeout. This will go on unless the idle timeout occurs, which is unlikely if there is enough traffic. By forcefully closing the connection, I intend to use DNS to provide a new backend server to connect to (at the next Java DNS cache refresh).

Note: according to the LDAP pooling doc

Bad connections are automatically detected and removed from the pool by the LDAP provider. The probability of a context ending up with a bad connection is the same regardless of whether connection pooling is used.

but i cannot find a definition of "bad connections". The only occurence of connection removal I can see is the idle timeout connection cleanup.

question from:https://stackoverflow.com/questions/65876259/ldap-connection-pooling-can-the-context-request-its-connection-to-be-removed-fr

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...