Use Correlation to Implement Asynchronous Communication Between Oracle Integration Cloud Process and Integration

August 9, 2019 | 7 minute read
Text Size 100%:

Introduction

Business Processes are often long-running. These processes usually send messages (or make asynchronous calls) to external systems and then wait for responses from the external systems to come in at a much later time. The Process component of the Oracle Integration Cloud (OIC) supports this type of asynchronous communication with a Send and Receive activity pair. To most efficiently use the system resources, a Process instance goes into a dehydration state when the instance reaches the Receive activity. This means the state of the instance is stored in the OIC run-time database, and the execution thread is released back to the system. When a response message arrives at an OIC server, the Process engine restores the state of the instance and continues executing the instance from the Receive activity. 

At any given time, there may be many instances of the same process waiting for response messages from the external systems. So the Process engine needs a way to identify which instance it needs to restore from a given incoming response message. The key to connect an incoming response message to a sleeping process instance is the Correlation.

Correlation

Correlation is a feature in the OIC Process to support asynchronous communication between Process instances. Please note that correlation only works between Process instances. It does not work when an inbound message is from a non-Process source. To use correlation, we must complete the following three steps.

Create a Correlation

Create a named correlation key; create one or more properties; add one or more properties to the correlation key. See images below

 

Initialize a Correlation Key

Before using correlation for inter-process communication, a process must initialize the correlation key properties with values in an activity. The values can come from Input payload *(Input Context) or Output payload (Output Context). The combination of correlation key property values must be unique in the OIC Process engine. An instance of the correlation key can only be initialized and correlated once. See the following image.

 

Use the Correlation Key

In the Receive activity, the same correlation key must be selected and its property values specified from the inbound message payload. See the following image.

 

The Demo Application

Now that we introduced Correlation, we can start building a simple application to demonstrate interactions between OIC Process and OIC Integration via Correlation. In this demo application, we will do the following,

  • Use a simple Process Webform to kick off a Process instance DemoProcess.
  • DemoProcess instance invokes a synchronous Integration DemoIntegrationSync.
  • DemoIntegrationSync invokes another asynchronous Integration DemoIntegrationAsync.
    • DemoIntegrationAsync serves as a simulation for an external asynchronous system such as a backend enterprise application.
  • DemoIntegrationAsync invokes an external resource
    • For simplicity reason, DemoIntegrationAsync invokes a mock-up REST service, which sleeps for 10 seconds, then returns a mockup payload. 
  • Finally, DemoIntegrationAsync makes a call back to the Process to complete the message exchange cycle.

 

Implementation

Step 1, Create two OIC Integration Applications

Following the video below to create two integrations.

Step 1 Create Integrations

 

The image below shows the Integration applications after Step 1. Note that the application DemoIntegrationSync is complete. But the DemoIntegrationAsync is incomplete. It is missing a call back to a process. The process, which will be created in the next step, is dependent on the DemoIntegrationSync as it calls the DemoIntegrationSync. This is the reason we create Integration applications first. The DemoIntegrationAsync is dependent on the Receive activity of the process. So after we create the process, we will come back and complete  the DemoIntegrationAsync. 

 

Step 2, Create the Main Demo Process

In this step, we will create the main demo process, DemoProcess. Follow the video below to complete the demo process.

Step 2 Create Process

Pay special attention to the Send and Receive activity pair to see how correlation is implemented. The following diagram illustrates the main DemoProcess and how it interacts with the Integration applications. Notice the gray line, it indicates the call back from the DemoIntegrationAsync is still missing. This is what we will do in Step 4. But let's do a quick test of the system we just completed in Step 3.

 

Step 3, Test the Demo without Callback

You can see a quick test on what we have built in the following video,

Step 3 Test witout Callback

Notice that the Receive activity is highlighted in yellow, which indicates it is active for this instance. Of course, it will never be completed because of no callback from the Integration.

 

Step 4, Implement the Callback

The video below shows details of adding a callback to the DemoIntegrationAsync.

Step 4 Implement the Callback

Notice that the callback is not directly to the Receive activity of the DemoProcess. Instead, an additional process is created to take the callback from the DemoIntegrationAsync,  and it then passes the payload to the Receive activity of the DemoProcess.  This is extra process is necessary because Correlation only works between two processes. The image below shows how messages and correction ID flow through different components.

Step 5, End to End Test with Callback

The following video shows the final end to end test.

Step 5 Final End to End Test

We can see the Receive activity in the main DemoProcess is completed (green) after a few seconds of delay. We can also see the two Integration instances. Due to the mock-up delay, we notice the DemoIntegrationAsync instance completed a few seconds later than the DemoIntegrationSync instance, as shown below.

 

Conclusion

This blog post described the correlation feature in OIC Process and demonstrated how correlation can be used to facilitate communications between the OIC Process and Integration.

 

Siming Mu


Previous Post

Implementing Data Security for IDCS-only users in Oracle Engagement Cloud - Part 1

Naveen Nahata | 4 min read

Next Post


Streamline Enterprise Access Management and Oracle Cloud Infrastructure Access Management with Federated Group Mapping

Olaf Heimburger | 5 min read