Concurrent Operations

Ldaptive provides some useful wrappers around LDAP operations to support threading and concurrency. This allows an application to execute multiple requests at once and then wait for the result as appropriate.

Searching is the most useful operation to perform concurrently. Multiple requests can be combined together and the client can wait until all operations have completed. All operations are executed on the same connection.

SingleConnectionFactory cf = new SingleConnectionFactory("ldap://directory.ldaptive.org");
cf.initialize();
SearchRequest request1 = new SearchRequest("dc=ldaptive,dc=org","(givenName=daniel)");
SearchRequest request2 = new SearchRequest("dc=ldaptive,dc=org","(sn=fisher)");
SearchOperationWorker search = new SearchOperationWorker(new SearchOperation(cf));

// to perform non-blocking searches
Collection<OperationHandle<SearchRequest, SearchResponse>> futures = search.send(new SearchRequest[] {request1, request2});

// to perform blocking searches
Collection<SearchResponse> responses = search.execute(new SearchRequest[] {request1, request2});

cf.close();

Implementations also exist for compare, add, modify, modify DN, and delete operations.