Thursday, October 27, 2011

Oracle SOA Suite – Finding the Running Instances of a Composite


Oracle SOA Suite – Finding the Running Instances of a Composite:

SQL Query:

We can use the below query to find all the Running instances of a Composite.
select * from composite_instance where state =0 or state=8 and composite_dn likexxxxxxxxx%'

Example query:

select * from composite_instance where state =0 or state=8 and composite_dn likedefault/GetOpenCompositeInstances!1.0%'

Java API:

The SOA Suite 11g provides a Java API’s that can be used to find the Running instances of the Composite.
The client API provides the Locator class to look up the Composite instances based on the filter.
The CompositeInstanceFilter class is used to filter the instance of the composite based on the condition.
The following code snippet will enable you to find all the open instances for a particular Composite process.
try
{
String compositeName="GetOpenCompositeInstances";
Hashtable jndiProps = new Hashtable();
jndiProps.put(Context.PROVIDER_URL,"t3://:");
jndiProps.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
jndiProps.put(Context.SECURITY_PRINCIPAL,"weblogic");
jndiProps.put(Context.SECURITY_CREDENTIALS,"password");
jndiProps.put("dedicated.connection","true");
Locator locator = LocatorFactory.createLocator(jndiProps);
CompositeInstanceFilter filter =new CompositeInstanceFilter();
filter.setState(CompositeInstance.STATE_RUNNING);
filter.setCompositeName(compositeName);
List compositeInstance = locator.getCompositeInstances(filter);
setVariableData("openCompositeInstances",new Integer(compositeInstance.size()).toString());
}catch(Exception e)
{
setVariableData("openCompositeInstances",e.getMessage());
e.printStackTrace();
}
Please refer the attached sample for your reference.

No comments:

Post a Comment