سؤال

I'm using Oracle's Java API Extensions to JNDI for accessing Oracle Internet Directory 11g (ldapjclnt11.jar library). A new dir context (connection) is created by calling ConnectionUtil.getDefaultDirCtx().

My question is: does this mechanism for creating a connection to the OID use some kind of connection pooling for the JNDI connections? if not, is there a way to pool the connections?

I'll be authenticating hundreds of users concurrently with OID, and I'm worried that the performance would suffer if I don't pool my OID connections.

هل كانت مفيدة؟

المحلول

Your fear is probably well founded: Pooling reduces garbage collection and pause times for socket connects, but I would highly advise checking your assumptions against a profiler like VisualVM. Every performance problem I've ever solved was not what I thought it was. Don't make blind guesses about your code!

Assuming you're on a Sun/Oracle JVM, there is a property to enable transparent pooling:

Hashtable env = new Hashtable();
env.put(Context.PROVIDER_URL, "ldap://localhost:389/o=myroot");
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put("com.sun.jndi.ldap.connect.pool", "true");
DirContext ctx = new InitialDirContext(env);

The ConnectionUtil class does not allow for setting this property, but you could try setting the following properties on your JVM if you have to use ConnectionUtil:

-Dcom.sun.jndi.ldap.connect.pool=true

Not sure if that will work though. You'll have to use wireshark or something to verify the behavior.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top