2 quick remarks about delayed tasks
I had already talked about the Sequence of event tasks in the last post. Now when reading again I was thinking about delaying tasks. You probably know the “delay before start” setting in provisioning tasks.
When you use it and the task is called it is scheduled with a delayed execution time as one can easily see when looking into the table mxp_provision:
The drawback here is that often customers want the delay configurable. And you want configurations to be done in one place, e.g. as global constants and not in some place deep in the workflow tree in the Identity Center console. My point is that it would be nice if such a delay could be configurable as global constant. And when reading the above post an idea crossed my mind how this can be done and I wanted to share this with you here. Let’s have a look at the following script:
var delay_in_seconds = Par.get ("DELAYINSECONDS");
// convert this into a "real" integer
delay_in_seconds = parseInt (delay_in_seconds);
// Thread.sleep needs the delay in milliseconds
var delay_in_milliseconds = delay_in_seconds * 1000;
Util_LogValue ("Waited " + delay_in_seconds + " seconds.");
So what we simply do is delegate the waiting to the work process and use a Java class for it. The task that uses it is here
and now we can use a global constant to provide the delay as a function argument.
The drawback here is that we block the entire work process for 20 seconds in this example, so if you intend to wait for a long time (e.g. if you’re having a grace period before deleting an entry) then this is perhaps not the best way. Depending on the load of your system you may end up with dozens or even hundreds of waiting work processes.
var v = new Vector ();
v.add ("a first element");
v.add ("another element");
for (var jj=0; jj
Last but not least one tricky thing: If you’re writing your own class which is not in the java package then you need to add a “Packages” in front of the package name:
var cc = new CleverClass ();