Getting the BPEL process status data

This recipe explains how to retrieve the current status of the BPEL process.

Getting ready

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>

How to do it…

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:

How to do it…

How it works…

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 (STATE_INITIATED)

1

Open and running (STATE_OPEN_RUNNING)

2

Open and suspended (STATE_OPEN_SUSPENDED)

3

Open and faulted (STATE_OPEN_FAULTED)

4

Closed and pending cancelled (STATE_CLOSED_ PENDING_CANCEL)

5

Closed and completed (STATE_CLOSED_COMPLETED)

6

Closed and faulted (STATE_CLOSED_FAULTED)

7

Closed and canceled (STATE_CLOSED_CANCELLED)

8

Closed and aborted (STATE_CLOSED_ABORTED)

9

Closed and stale (STATE_CLOSED_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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset