Tuesday, October 25, 2011

Oracle SOA Suite 10g – Finding the Open BPEL Instances

Oracle SOA Suite 10g - Finding the Open BPEL Instances:

SQL Query:

We can use the below query to find All the Open BPEL instances(Open and Running,Open and Suspended and Open and Faulted)
select * from orabpel.cube_instance where (state=1 or state=2 or state=3) and process_id='xxxxxxxxx'

Java API:

The Oracle BPEL Process Manager Server provides a Java API’s that can be used to find the Open BPEL instances.
The BPEL process client API provides the Locator class to look up the process and find the instances.
listInstances(WhereCondition wc) method can be used to find the instances based on the where condition.
WhereCondition class can be used to create the queries.

The following code snippet will enable you to find all the open instances (Running, Suspended, and Faulted) for a particular BPEL process.

Properties props = new Properties();
props.setProperty("orabpel.platform", "ias_10g");
props.setProperty("java.naming.security.principal", "oc4jadmin");
props.setProperty("dedicated.rmicontext", "true");

String processId = "xxxxxxxxxxxxxx";
Locator locator;
locator = new Locator("domainname", "password", props);

//Set the processed id
WhereCondition WhereProcessId = new WhereCondition( "process_id = ?" );

//Set the state 1 - instance Open and Running
WhereCondition WhereStateOpenAndRunning = new WhereCondition( "ci_state=?" );

//Set the state 2 - instance Open and suspended
WhereCondition WhereStateOpenAndSuspended = new WhereCondition( "ci_state=?" );

//Set the state 2 - instance Open and faulted
WhereCondition WhereStateOpenAndFaulted = new WhereCondition( "ci_state=?" );

WhereProcessId.append("and").append("(").append(WhereStateOpenAndRunning).append("or").append(WhereStateOpenAndSuspended).append("or").append(WhereStateOpenAndFaulted).append(")") ;
IInstanceHandle[] instanceHandles = locator.listInstances( WhereProcessId );
setVariableData("openInstanceCount",new Integer(instanceHandles.length));
}catch(Exception e)

This code snippet can be modified to find only the open and running instances or open and suspended instances or open and faulted instances.
Please refer the attached sample for your reference.


  1. Thanks Albin.

    Is that necessary to mention Credential over here in Properties ??
    Can we use another way or skip it ?? What If we are looking towards the Remote Server ?

  2. Hi Kamal

    We have to specify the credential to connect to the BPEL domain but the credential details can be moved to a property file and the same can be refereed here.

    We can use the same code to connect to the remote server also but the connection details need to be changed.

    Albin I