Wait in OIC Orchestration process

While working on integrations there are times you would need the need to add the functionality of Wait in OIC Orchestration process.

Sometimes the called service takes some time to come up with a response element populated and you may need to make your process wait till response is received. Lets see how to implement.

The Wait Activity in OIC

The wait action enables you to delay the execution of an integration for a specified period of time. You can Use this action in scheduled and asynchronous orchestrated integrations. A typical use for this action is to invoke a specific operation at a certain time.

Though Scheduled orchestration provides that option, you won’t find this in the app-driven orchestrations, and would not be able to add the wait activity as it will be disabled.

Then how do we make our synchronous process wait? There are few workarounds which we will see.

The Options to add time delay in OIC Synchronous Process

The most used options to add wait are

  • Create a JavaScript program and add to OIC libraries.
  • Create a condition and add a while loop till the condition is true and call the target service inside the loop.

1. Let see how to use javascript to add Wait in OIC

Sample JavaScript

function sleep(milliseconds) {
  var start = new Date().getTime();
  for (var i = 0; i < 1e7; i++) {
    if ((new Date().getTime() - start) > milliseconds){
return start ;

Save the above javascript in a .js file and upload to the libraries of oic

image 40 Wait in OIC Orchestration process 1

Once uploaded select the input and output datatypes (string in our case)

image 32 Wait in OIC Orchestration process 2

After that, this function will be visible in the user-defined functions and can be used wherever required.

image 33 Wait in OIC Orchestration process 3

When you drag this function to expression builder it will show up as ns6:sleep ( ). And you can add your time as a parameter. (your namespace can be different)

e.g ns6:sleep (60000 )

image 35 Wait in OIC Orchestration process 4

image 36 Wait in OIC Orchestration process 5

You can also use the javascript action to call within your process

image 37 Wait in OIC Orchestration process 6

The called sleep function will be part of the process flow

image 38 Wait in OIC Orchestration process 7
image 39 Wait in OIC Orchestration process 8

Run your process and it would wait for that number of milliseconds. There is a limit to the parameter and the process may not wait for longer periods, resulting in Timeout Error. So use this for short time waits.

2. Using a Conditional Loop for Wait in OIC

Sometimes there are rest services whose payload values change as it undergoes some transaction within the application. A common example is PO requisition not having PurchaseOrder when it’s created but after some time the element PurchaseOrder get populated after the internal process within the application gets completed.

image 41 Wait in OIC Orchestration process 9

And your requirement is to fetch the PO number in the Flow for further processing. The initial Rest call to the requisition service will give you null for PO number.

image 43 Wait in OIC Orchestration process 10
  1. Create a variable (e.g povar) and assign the response of get porequistion po number element (is null initially) to povar
  2. Create a while loop with condition povar = null
  3. Call the po req service again inside the loop
  4. Assign the output of PO number element to povar inside the loop again.

When executed this loop will continue till the PO number is generated and assigned to the povar variable which can be used further.

image 44 Wait in OIC Orchestration process 11
While loop condition

3. Create a Counter loop

You can also create a counter for loop and inside the loop call a OIC dummy process which does not do any processing. Use the For loop for that number of times which can suffice your wait time.

With the above 3 methods, you can make your App driven orchestration process wait and apply these logic in different scenarios.

OIC MasterClassTrainings

Suggested Readings


Why is the Wait Activity Disabled?

The Wait activity is disabled in App Driven orchestrations. Try using scheduled orchestrations.

How much time we can wait?

For Short periods otherwise the processes timeouts.

We will be happy to hear your thoughts

Leave a reply

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
Best Wordpress Adblock Detecting Plugin | CHP Adblock
Cloud Technologies Blog
Compare items
  • Total (0)
Shopping cart