In this post I have shared my experience of designing and developing an OIM schedule job that uses multi threaded approach for updating data in OIM using APIs. I have used thread pool (in particular fixed thread pool) pattern in developing the OIM schedule job. The thread pooling pattern has noted advantages compared to thread per task approach. I have listed few of the advantage here
·Threads are reused
·Creation and tear-down cost of thread is reduced
·Task execution latency is reduced
·Improved performance
·Controlled and efficient management of memory and resources used by threads
More about java thread pool http://docs.oracle.com/javase/tutorial/essential/concurrency/pools.html
The following diagram depicts the high-level architectural diagram of the schedule job that process input from a flat file to update OIM process form data using fixed thread pool approach
The custom scheduled job shared in this post is developed to meet following requirement
1)Need to process a CSV extract that contains identity, account identifying key and list of data to be updated on an existing OIM resource account.
2)CSV file can contain data for multiple resources configured in OIM
3)List of attribute to update and mapping between CSV column to OIM fields may vary between resources
The following are three Java class developed for this requirement (I have given only prototype of the code that explains how to use thread pools in schedule task)
CustomScheduler.java - Implementation of TaskSupport class that reads and passes the parameters configured on the schedule job to Thread Executor class.
package com.oracle.oim.scheduler; import java.util.HashMap; publicclass CustomScheduler extends TaskSupport { publicvoid execute(HashMap options) throws Exception { /*Read Schedule Job Parameters */
} public HashMap getAttributes() { returnnull; } publicvoid setAttributes() { } } |
MultiThreadDataRecon.java – Helper class that reads data from input file, initialize the thread executor and builds the task queue.
package com.oracle.oim.bo; import<required file IO classes>; privateintnoOfThreads; public MetaDataRecon(<required params>, int noOfThreads){ /** privatevoid init() throws Exception { try { // Initialize CSV file reader API objects if (noOfThreads > 1) { /* Initialize TaskProcess clas s which will be executing task TaskProcessor.initializeConfig(params); /** publicvoid reconcile() throws Exception { /** privatevoid processRow(String row) { } } |
TaskProcessor.java– Implementation of “Runnable” interface that executes the required business logic to update data in OIM.
package com.oracle.oim.bo; import<required APIs> class TaskProcessor implements Runnable { //Initialize required member variables /* /* /** privatevoid processData() { try{ //Find the user in OIM using the identity matching key value from CSV } } |