Sunday, May 22, 2016

OIM Scheduled Job Multi-threading Example

Tested On: Oracle Identity Manager 11.1.2.3.0
Description: Demonstrates using multi-threading in an Oracle Identity Manager scheduled job. The scheduled task example applies changes to OIM users using data given from a CSV file. A thread is created per data entry in CSV file and uses OIM API service to apply changes to the OIM user.
References: 
https://blogs.oracle.com/OIM11gR2/entry/oim_11g_multi_thread_approach

Files
FlatFileUserModificationTestDriver.java : Used to test remotely via OIMClient. Not part of plugin.

users.csv : Sample CSV file.

UserProcessor.java : Runnable object used for threading.

FlatFileUserModification.java : OIM scheduled task code.

FlatFileUserModificationMetadata.xml and plugin.xml : Metadata for OIM scheduled task and OIM plugin.


Scheduled Job Parameters
Delimiter : Separator used in flat file
File Path : Absolute path of file on the machine where OIM is deployed
Key Attribute Name : User attribute name to uniquely identify OIM user
Number of Threads : Number of threads in pool

Scheduled Job Parameters

Things to Take Note Of
1. Had to use "Platform.getServiceForEventHandlers" instead of "Platform.getService" when using OIM API service in threading context. The exception below is thrown when using "Platform.getService" for multi-threading in a scheduled job.

java.lang.NullPointerException
 at oracle.iam.request.impl.RequestEngine.performValidations(RequestEngine.java:4628)
 at oracle.iam.request.impl.RequestEngine.doOperation(RequestEngine.java:4520)
 at oracle.iam.impl.OIMServiceImpl.doOperation(OIMServiceImpl.java:43)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
 at oracle.iam.platform.utils.DMSMethodInterceptor.invoke(DMSMethodInterceptor.java:35)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
 at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
 at $Proxy353.doOperation(Unknown Source)
 at oracle.iam.identity.utils.Utils.invokeUnifiedService(Utils.java:3849)
 at oracle.iam.identity.usermgmt.impl.UserManagerImpl.modify(UserManagerImpl.java:648)
 at oracle.iam.identity.usermgmt.impl.UserManagerImpl.modify(UserManagerImpl.java:741)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
 at oracle.iam.platform.utils.DMSMethodInterceptor.invoke(DMSMethodInterceptor.java:35)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
 at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
 at $Proxy476.modify(Unknown Source)
 at com.blogspot.oraclestack.objects.UserProcessor.run(UserProcessor.java:91)
 at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
 at java.lang.Thread.run(Thread.java:662)

]]

1 comment:

  1. Easy "water hack" burns 2 lbs OVERNIGHT

    Over 160,000 women and men are hacking their diet with a easy and SECRET "liquid hack" to drop 1-2lbs every night while they sleep.

    It is effective and it works on everybody.

    Here's how to do it yourself:

    1) Go grab a glass and fill it up with water half full

    2) Proceed to use this amazing hack

    so you'll become 1-2lbs thinner as soon as tomorrow!

    ReplyDelete