Sometimes we need to explicitly add a wait in immediate/synchronous(App Driven) Integrations.
For Example: We have many inbound integrations where callback is not possible/allowed by Oracle, in that case we need to keep on checking the status of submitted ESS jobs. For this we can create a generic app driven integration which will take request ID as parameter and return its status.
If Out of many calls one of the call fails while checking the status of ess job and we want to retry checking after a wait.
This may happen as ERP services may not have 100% up time and may fail to provide the response in one of the many calls. This should not hamper our integration flow as by the next call to check status the Services will be up and it might give us the proper response.
Since this will be a synchronous/Immediate app driven integration having for eg. Rest adapter as trigger, OIC does not allow us to add wait. The wait action will be disabled as shown in below screenshot.
Now question comes that how do we add a wait in these integrations if required?
One of the answer to this is Using Javascript.
We can write a simple JavaScript function which will take number of milliseconds as parameter. Add this function to the Libraries in OIC as shown in below screenshots.
Below is the Javascript function that we can use.
function wait(milliseconds){
var start = new Date().getTime();
while (true){
if ((new Date().getTime()-start)>milliseconds){
break;
}
}
return start;
}
Below screenshots shows how we can call this function from our OIC integration:
Note: Js action call has timeout limit of 15 secs so our single wait time has to be <=15 secs.
If we want more wait time then we can call this function in a loop, with each call <=15 secs.
No comments:
Post a Comment