This recipe explains how to retrieve the current status of the BPEL process.
In order to complete this recipe, we will extend the output variable of the BPEL process. Thus, we open the BPEL_and_Java_2_0.xsd
schema file and add an additional element to retrieve the BPEL process status data:
<element name="processResponse">
<complexType>
<sequence>
<element name="day_of_date" type="string"/>
<element name="exchangeMsg" type="string"/>
<element name="prc_inst_id" type="long"/>
<element name="prc_inst_title" type="string"/>
<element name="prc_inst_creator" type="string"/>
<element name="prc_status" type="string"/>
</sequence>
</complexType>
</element>
Open the BPEL_and_Java_2_0
process and add the Java Embedding activity (Java_Process_Status
). Double-click on the Java_Process_Status
activity and put in the code snippet:
String prc_status= getStatus(); if (prc_status != null) setVariableData("outputVariable", "payload", "/client:processResponse/client:prc_status", prc_status);
The code retrieves the BPEL process status and sets its value to the BPEL process output variable element <prc_status>
.
Let us now deploy and instantiate the BPEL process. In Audit Trail we can observe the output variable filed with data about running the BPEL process:
The BPEL processes that run in Oracle SOA Suite have a number of states in which the BPEL process can reside:
State |
BPEL process |
---|---|
0 |
Initiated ( |
1 |
Open and running ( |
2 |
Open and suspended ( |
3 |
Open and faulted ( |
4 |
Closed and pending cancelled ( |
5 |
Closed and completed ( |
6 |
Closed and faulted ( |
7 |
Closed and canceled ( |
8 |
Closed and aborted ( |
9 |
Closed and stale ( |
For example, if we run the following SQL statement on the Oracle database (assuming we have Oracle XE database):
SELECT CIKEY, c.status, CASE state WHEN 0 THEN 'initiated' WHEN 1 THEN 'open.running' WHEN 2 THEN 'open.suspended' WHEN 3 THEN 'open.faulted' WHEN 4 THEN 'closed.pending_cancel' WHEN 5 THEN 'closed.completed' WHEN 6 THEN 'closed.faulted' WHEN 7 THEN 'closed.cancelled' WHEN 8 THEN 'closed.aborted' WHEN 9 THEN 'closed.stale' ELSE 'unknown' END state_text FROM dev_soainfra.cube_instance c ORDER BY c.CIKEY;
We can see the same information as the getStatus()
method in the Java Embedding activity will report to us.