How to Pause Without Blocking Job Queue in One Identity Manager Scripts?

I’m developing scripts for a customer in One Identity Manager and noticed that using Thread.Sleep tends to block the Job Queue, making the entire process slower. Since the process involves bulk operations with many items in the queue, I’m looking for a more efficient way to pause or wait without blocking other jobs. Is there a recommended approach on the Job Server, such as waiting for events or using a more efficient timer, to optimize this kind of scenario?

  • Hi Barry, Can I use it on a script?

  • No, it's a process step component.  Perhaps if you explained your full use case / issue, the forum might be able to help.

  • It is definitely a bad idea to use SLEEP or WAIT in a script as it blocks the execution slot. If you have open transactions it might even block the whole system via DB-locks.
    Generally your script should be small enough to only do "atomic" operation, i.e. do something short that either fully fails or fully succeeds (reasonably fast). 

    If you have to do a multi-step operation the recommended way is to have a multi-step process that calls multiple scripts, one per step. Something like 1. create some assignement, 2. wailt till dependent objects are assigned, 3. depending on the result send mail.
    Waiting in the process can be done with the DELAY component. In most cases I found an actual check for the blocking condition and a number or retries on the process step more suitable. 

    I had some cases where I actually had a script that did some first operation, then attempted the second operation. If that fails it throws an errors and the process does a retry on the same script. Not the first operation is already present and the second is attmpted again (after process latency and retry).

    Another option is for your script to detect the wait-conditon and instead of waiting, to fire an event/process with a delayed start-time that does the second part of the operation.

    Overall: Look at your business process and implement is as a (series) of OIM-processes. Scripts may be part of the process, but generally should only implement small operations within the process

  • In my script, I check whether an API request was successful or failed, and based on the result, I close the IT Shop request accordingly. To perform this check, the script needs to wait for the API response to confirm success or failure. Depending on the error returned, I also want to add a specific reason to the IT Shop decision. I can send it to you check

  • If this is a real 2 step API call, i.e. first do the API request, wait then do a second request for the status, I would advise to split those into 2 scripts that are called in 2 process steps. You can use out-values in case you need to pass information between the steps (like a sessionID), or you put them in a (custom) field in your basetable. Those 2 steps can be in a single process, advised if the result is available somewhat fast (minutes). Or you can have schedule and separate process for the second "resultcollection", advised if you want/can process multiple results and/or the results take longer to get (like result from an external ticketing system).

    If it is really just 1 API call that takes rather long to finish, you are out of luck speeding the script up. In that case I would advise to configure a (or multiple) separate JobQueue for just processing those Jobs, maybe with an increased number of EXTERNAL slots. That way they do not block the rest of the system while waiting.