OIM 11g R2 – Running Reconciliation in a Multi-Threaded Environment

Below is the sample Java code which provided method forĀ invoking reconcilaition that is not based on scheduled tasks in a multi-threaded environment.

Public class UserNonSTBasedRecon{
private AtomicInteger threadCount =new AtomicInteger(0);
@Test
public void testCreateUsersUsingNonScheduleTaskConnectorWithThreads()
throws Exception {
Thread t = new CreateEvent();
t.start();
Thread t2 = new CreateEvent();
t2.start();
while (true) {
Thread.currentThread().sleep(5000);
if (threadCount.get() == 2){
ReconOperationsService reconServ =
getService(ReconOperationsService.class);
reconServ.callingEndOfJobAPI();
break;
}
}
}
public class CreateEvent extends Thread {
Override
public void run() {
String ctxFactory = "weblogic.jndi.WLInitialContextFactory";
OIMProfileReader reader = new OIMProfileReader();
String appServerType = reader.getString("appserver.type");
String hostName = reader.getString("weblogic.host");
String port = reader.getString("weblogic.port");
String serverURL = "t3://" + hostName + ":" + port;
System.out.println("Server URL is : " + serverURL);
System.out.println("Context Factory is : " + ctxFactory);
Hashtable<String, String> env = new Hashtable<String, String>();
env.put(OIMClient.JAVA_NAMING_PROVIDER_URL, serverURL);
env.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL, ctxFactory);
.
OIMClient client = new OIMClient(env);
String username = "SYSTEM_ADMINISTRATOR_USERNAME";
String password = "SYSTEM_ADMINISTRATOR_PASSWORD";
try {
client.login(username , password.toCharArray());
} catch (LoginException e1) {
throw new SuperRuntimeException(e1.getMessage(), e1);
}
String uniq2 = getRandomLong(10000).toString();
long jobId = getRandomLong(10000);
ContextManager.setValue(Constants.JOB_HISTORY_ID, new ContextAwareNumber(jobId));
ContextManager.setValue(Constants.JOB_NAME_CONTEXT, new ContextAwareString(jobId +""));
ReconOperationsService recon;            
try {
recon = getService(ReconOperationsService.class);
int count = 50;
HashMap<String, String> hm = new HashMap<String, String>();
ArrayList<Long> eventKeys = new ArrayList<Long>();
for (int i = 0; i < count; i++) {
hm.put("UserLogin", uniq2 + "ThreadTest" + i);
hm.put("FirstName", uniq2 + "Thread" + i);
hm.put("lastname", "Test");
hm.put("Type", "End-User");
hm.put("OrganizationName", "Xellerate Users");
hm.put("EmpType", "Full-Time");
hm.put("Middlename", "MID");
System.out.println("Creating Recon event i = "+ i);
long rceKey = recon.createReconciliationEvent("Xellerate User", hm, true);
eventKeys.add(rceKey);
}
assertEquals(count, eventKeys.size());                
} catch (Exception e) {
throw new SuperRuntimeException(e.getMessage(), e);
} finally {
threadCount.set(threadCount.get()+1);
ContextManager.popContext();
}
}
}
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *