You might often get this question from users during support and you often be in a situation to see if the order reached JMS Producer or if it EBF failed for this order or whether it entered into SOA itself!
This post discuss about various message tracking mechanisms Oracle SOA provides and how business Key identifiers can be used in tracking SOA instances.
As SOA is getting mature, the ability to track instances in SOA is getting more and better!
The Classic Title/Name method
For the very old 10g release up to latest 11g release, we have a way of setting a title to a BPEL Instance(in 10g) and to a Composite(in 11g).
There are various blogs that talks about that.
However a thing to notice in 11g is you have two titles,
- Composite Instance Title:
- Title for a Composite Instance
- Stored in TITLE column of COMPOSITE_INSTANCE table.
- Can be set through ora:setCompositeInstanceTitle() xpath API or setCompositeInstanceTitle in Java Embedding.
- Searchable through Enterprise Manager using Name column in Instance Search page.
- BPEL Title:
- Title for a BPEL Instance.
- Stored in TITLE column of CUBE_INSTANCES table.
- Can be set through setTitle API in Java Embedding.
- Not Searchable through Enterprise Manager
Composite/BPEL Indexing
In 10.1.3.4, Oracle Introduced Indexing in BPEL through CI_INDEXES table and a text box in left side of Instance Search page:
To find the current values of the instance indexes in 10.1.3.4, Go to any Instance, Click More.
To Query from database using indexes, use the following query using CUBE_INSTANCE and CI_INDEXES tables:
SELECT *
FROM ORABPEL.CUBE_INSTANCE t1,
ORABPEL.CI_INDEXES t2
WHERE
t1.CIKEY = t2.CIKEY
AND t2.INDEX_1 = <Business Key>
You can set the index to a BPEL instance by using setIndex API in Java Embedding Activity. You can set up to 6 indexes – So 6 searchable business keys for an instance.
With 11g Composites, Oracle replicated the same set of index columns in COMPOSITE_INSTANCE table, but, the instance search in enterprise manager doesn’t have index based search yet(as of patch set 2). But since the fields are available in database, we could write our own xpath function to set indexes like below:
public class SetCompositeInstanceIndex implements IXPathFunction {
public Object call(IXPathContext context, List args) throws XPathFunctionException{
try{
int index_number;
String index_value;
if(args == null || args.size() <2){return "";}
try{
index_number = Integer.parseInt(args.get(0));
}(NumberFormatException E){
throw new XPathFunctionException(E.getMessage());
}
if(index_number <1 || index_number >6){
throw new XPathFunctionException("Invalid Index Number: " + index_number);
}
index_value = (String)args.get(1);
Map props = (Map)context.getVariableValue(null, null, "xpath-function-data");
ICubeContext ctx = (ICubeContext)props.get("ICubeContext");
long cid = Long.parseLong(CubeContextHelper.getCubeInstance(ctx).getCompositeInstanceId());
InstanceManager mgr = CubeContextHelper.getServerManager(ctx).getCubeServiceEngine().getInstanceManager();
CompositeInstanceBean bean = mgr.getCompositeInstanceBean(cid);
switch(index_number){
case 1: bean.setIndex1(index_value); break;
case 2: bean.setIndex2(index_value); break;
case 3: bean.setIndex3(index_value); break;
case 4: bean.setIndex4(index_value); break;
case 5: bean.setIndex5(index_value); break;
case 6: bean.setIndex6(index_value); break;
}
mgr.persistCompositeInstanceBean(bean);
return "";
}catch (Exception e){
throw new XPathFunctionException(e.getMessage());
}
}
}
Although the search is still not available in EM, we could use DB to easily find the instance using the below query:
SELECT *
FROM
DEV_SOAINFRA.COMPOSITE_INSTANCE
WHERE
INDEX1 = <Business Key>
Composite Sensors
11g feature – Recommended approach if you have variable number of business key to be used in the search. If you have just one business key (title would serve the purpose) and index could be used for up to 6 values (No EM based search though for now).
- Stored in COMPOSITE_SENSOR_VALUES table.
- Extensible to any number of keys as it is stored at row level as key value pairs
- Can be Searched through Enterprise Manager – Only within Composite Instances page, I did not find them yet in all instance search page.
To set the composite sensor value, right click the Service in the composite, select Composite Sensors – Add key – Select Expression/Variable. You can also add filter condition based on expression.
Select Expression/Variable/Properties
The fields can be searched from Enterprise Manager in Composite Instances page:
To query from the database, it is as simple as querying Composite_Sensor_value table using Sensor name and component name.
SELECT *
FROM
DEV_SOAINFRA.COMPOSITE_SENSOR_VALUE
WHERE
COMPONENT_NAME='messagetracking_client_ep'
AND SENSOR_NAME='SearchKey1'
AND STRING_VALUE = '12345'
Other Observations
From the observations on Composite_instance table, Oracle has also introduced a field called “TAGS” which can also be used by writing custom xpath function. However, all these would be useful if they could get them into instance search page in enterprise manager, otherwise it would be only at database level.
While all the methods listed above are intrusive and if it has to be applied to existing instances, the code change have to happen and if you have a lot of them, it would be difficult to change the existing. If you are looking from some non-intrusive ways, go through this other article by Chintan Shah here where he shared about some intrusive ways of setting title to the existing flows by using EJB Poller on Cube Instance table. (I haven’t tried yet though)
Have you been there in the same situation and what’s your solution was, Please share!