Skip to main content

Send and Receive Task example in Oracle BPM

This post talks about Oracle BPM process communication with Asynchronous service.

When we talk about BPM process communication with other processes or services, Those processes or services can be synchronous or asynchronous.

Synchronous process/service can be invoked with Service Call flow object in Oracle BPM. It will be a straight forward approach,just by adding WebService adapter at external references and using service task to invoke the service.

In case of Asynchronous process /service,we must use send /receive task or throw/catch message events when designing flows in BPM.
Summary : Asynchronous process wont wait for response to be returned immediately. As soon as its been invoked ,the process will be running in the background.Its the responsibility of calling process  to make sure to look for callback response from asynchronous process for the sent request. In order to identify the correlation between request and response , the design has to be made in such a way to use/add a unique identifier in the application design to be used as correlation.Correlations are used to identify the instance that receives the message in the peer process.
Defining a correlation for a  process enables you to identify an instance in another process through the instance state and send a message to that specific instance.Check more about correlation in here.
In the below example we have added ID variable to correlate request and response.

For the sake of demonstration , I have created a simple SOA(BPEL) Asynchronous process. It can be find in this github location.
The SOA Asynchronous process accepts input and waits for 2 mins and then will send the response as callback operation.

Step1 : Create and IO xsd in order to perform data flow in the process. In this case, I have created simple xsd with input and output string elements.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns="http://org.prabhas.ande/Async/V1"
            targetNamespace="http://org.prabhas.ande/Async/V1"
            elementFormDefault="qualified">
  <xsd:element name="RequestElement" type="Request"/>
  <xsd:element name="ResponseElement" type="Response"/>
  
  <xsd:complexType name="Request">
    <xsd:sequence>
    <xsd:element name="Input" type="xsd:string"/>
    <xsd:element name="ID" type="xsd:string"/>
    </xsd:sequence>
  </xsd:complexType>
  
  <xsd:complexType name="Response">
    <xsd:sequence>
    <xsd:element name="Output" type="xsd:string"/>
    <xsd:element name="ID" type="xsd:string"/>
    </xsd:sequence>
  </xsd:complexType>
    
</xsd:schema>

Step2 : Create BPM Asynchronous process by providing input and output arguments derived from above given xsd.








Step3: Introspect AsyncSOABPEL process as a webservice  adapter.



Step4: Perform Asynchronous service invocation with "Send Task" activity.
        i) Drag and drop and Send Task activity in the location where you want to invoke Asynchronous process by providing necessary input arguments. And select the Asynchronous service request operation.
                 

        ii) Select correlation and create correlation key by adding "ID" variable as identifier. And make sure to select Initiate check box for Send Task's correlation.


         



Step5: Add "Receive Task" to get response back from Asynchronous service. The Receive task definition should be calling Callback Operation of Asynchronous Service.
 
     i) Drag and Drop "Receive Task" to the desired location in your process flow. And then choose Callback Operation as implementation of the task.



ii) Select correlation link and use the same correlation key with ID element. So that the callback matches the request ID value and will retrieve the corresponding data from Asynchronous service.Make sure not to select Initiate checkbox for Receive Task's correlation.




Step 6: And then perform DataAssocation of Input and Output arguments and Data objects to flow the data in the process.

Step7: That't it , Deploy the process and test.

Test Results : Below highlighted Request and Callback operation response indicates the proper flow of Asynchronous request and response.




Code related to this example can be found in this github location.


Comments

Popular posts from this blog

How to control CUDA Devices to be used in Windows 10 for Keras/Theano/TensorFlow training

I've two 1080ti GPUs , I would like to use only one of the device for DeepLearning Training purpose,Most of the google suggestions advising to use CUDA_VISIBLE_DEVICES environment variable.Setting CUDA_VISIBLE_DEVICES either in windows environment variables are as programmatic way dint help much. But below approach helped to control the GPU usage for CUDA operations. Open NVIDIA Control Panel" by right clicking on the desktop screen. And select CUDA-GPUs to the desired gpu you want to use for DL training, In my case: I chose 2nd GPU Peace!!

Send/Receive task vs Throw/Catch Message events in Oracle BPM

In Oracle BPM "Service task" is used for invoking Synchronous web-service calls. It wont be useful for Asynchronous service calls. To deal with  Asynchronous service calls,  Send/Receive or Throw/Catch events need to be used. There are few differences and similarities between Send/Receive and Throw/Catch Message events. Please have a look at them below. Send/Receive Task Throw/Catch Message Events Can it be used to initiate task? Yes Yes Can it be used to call/invoke Synchronous services/processes? No No Can it be used to call/invoke Asynchronous services/processes? Yes Yes Does correlation/conversation need to be set to deal with Asynchronous tasks? Yes Yes Can it have boundary events associated to it? Yes No Can these pair be used to create synchronous process /service? Yes Yes Can these pair be used to create Asynchronous process /service? Yes Yes Send and Receive task example with boundary events attached to it can be fou