Wednesday, April 30, 2014

How to create a custom scheduled job in OIM R2?

First of all decide on the number and type of arguments that will be passed to your scheduled job. Now create a class file for the scheduled job. The class should extends oracle.iam.scheduler.vo.TaskSupport.

There are 3 abstratct methods that needs to be overridden.
execute (HashMap map)
getAttributes ()
setAttributes ()

The execute is the method that gets executed when the scheduled job is triggered. It accepts an argument Hashmap which contains the arguments passed to the scheduled job from OIM UI.


We can get the arguments passed to the job and from the hashmap and then we can write our business logic in the execute method. For demo purpose we are just printing the arguments to the console.

We have just created a demo scheduled job which takes two arguments and just prints them to console.

  1. Create the class file as mentioned above. Compile it into jar file.
  2. Create a plugin.xml file as below.
  3. Create a scheduler metadata file as below. The name of the file as well as scheduler should be same (Sample_Scheduler.xml).
  4. Create a directory structure as below:
  5. Inside the lib directory place the jar file.
  6. Inside META-INF place the scheduler metadata xml file. Alternatively you can register the scheduler metadata file to the mds.
  7.  Create a zip selecting the above two folders and plugin.xml. If you are in development stage you can place the zip inside <OIM_HOME>/plugins in all the nodes. Once you are done with the development its ideal to register the plugin to the database.
  8. Next step is to create the scheduled job. Go to system administration console>Scheduled jobs.

  9. Click on the new button. Search the job with the name.Select the job and confirm.
  10. Select the job and confirm, fill in the details as below and Save.
  11. You can search and run it now. As per the code both the arguments will get printed on the console (oim_server.out file).




    The scheduler files are available here 
  12.  
    If you have any questions or need more details, please update the comments. I will try my best to answer them.

    -gaurav
     
     
     


3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. How to show failure message in ui of scheduled task on failed of scheduled task

    ReplyDelete
  3. How to show failure message in ui of scheduled task on failed of scheduled task

    ReplyDelete