« Using the new 11g SOA Suite API - changes to 10.1.3x | Main | SOA Suite 11g - api part 3 - finding instances through composite sensor values »

SOA Suite 11g - api tricks part 2 - finding instances

In the last post we learned how to use the Locator to find a Composite (locator.lookupComposite(compositeDN);), and invoke it through a DeliveryService.

The next step is to use the API to find its instances and get some meaningful information, e.g. its instance id - what components executed and what not.


Composite composite =
locator.lookupComposite("default/OrderBookingComposite!1.0");
/*
* retrieve instances, we are already on a composite, no need to set the
* DN
*/
CompositeInstanceFilter filter = new CompositeInstanceFilter();
filter.setMinCreationDate(
new java.util.Date((System.currentTimeMillis() - 20000)));

// get composite instances by filter ..
List obInstances = composite.getInstances(filter);

// for each of the returned composite instances..
for (CompositeInstance instance : obInstances)
{
System.out.println(" DN: " + instance.getCompositeDN() +
"Instance: " + instance.getId() +
" creation-date: " + instance.getCreationDate() +
" state (" + instance.getState() + "): " +
getStateAsString(instance.getState()));

// setup a component filter
ComponentInstanceFilter cInstanceFilter =
new ComponentInstanceFilter ();

// get child component instances ..
List childComponentInstances =
instance.getChildComponentInstances(cInstanceFilter);

// for each child component instance (e.g. a bpel process)
for (ComponentInstance cInstance : childComponentInstances)
{
System.out.println(" -> componentinstance: " +
cInstance.getComponentName() + " type: " +
cInstance.getServiceEngine().getEngineType()+
" state: " +
getStateAsString(cInstance.getState()));
}

// retrieve composite sensors
List sensorData = instance.getSensorData();
for (SensorData data : sensorData)
{
System.out.println(" -> Sensor: " + data.getSensor().getName() +
" data: " + data.getData());
}
}


To make the compo(site/nent) states readable - here is the conversion method:

private String getStateAsString (int state)
{
// note that this is dependent on wheter the composite state is
// captured or not
if (state == CompositeInstance.STATE_COMPLETED_SUCCESSFULLY)
return ("success");
else if (state == CompositeInstance.STATE_FAULTED)
return ("faulted");
else if (state == CompositeInstance.STATE_RECOVERY_REQUIRED)
return ("recovery required");
else if (state == CompositeInstance.STATE_RUNNING)
return ("running");
else if (state == CompositeInstance.STATE_STALE)
return ("stale");
else
return ("unknown");
}

The above code executed against the FusionOrderDemo BamOrderBookingComposite prints the following:

DN: default/BamOrderBookingComposite!1.0Instance: 40103 creation-date: Thu Jul 30 12:31:24 PDT 2009 state (-1): unknown
-> componentinstance: EvaluatePreferredSupplierRule type: decision state: success
-> componentinstance: FulfillOrder type: mediator state: success
-> componentinstance: InternalWarehouseService type: bpel state: unknown
-> componentinstance: OrderProcessor type: bpel state: unknown
-> componentinstance: RequiresApprovalRule type: decision state: success
-> componentinstance: PartnerSupplierMediator type: mediator state: success
-> Sensor: CreditCardAuthResultSensor data: APPROVED
-> Sensor: OrderBookingCompositeProcessorResult data: 900
-> Sensor: OrderProcessingStart data: Order 900

On a side note - in case you don't want to start searching for the APIs, and packages .. All of those classes used are in

oracle.fabric.common.*, oracle.soa.management.facade.* and
oracle.soa.management.util.*

TrackBack

TrackBack URL for this entry:
http://blogs.oracle.com/mt/mt-tb.cgi/13090

Comments (1)

Clemens Utschig (author):

the libraries you need are fabric-common.jar, weblogic.jar, and soa-infra-mgmt.jar.

If you check my other posts (you can find all the jars / paths you need in the build scripts)

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About This Entry

This page contains a single entry from the blog posted on July 30, 2009 11:34 AM.

The previous post in this blog was Using the new 11g SOA Suite API - changes to 10.1.3x.

The next post in this blog is SOA Suite 11g - api part 3 - finding instances through composite sensor values.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type and Oracle