Wednesday, May 11, 2011

BPEL instance title in BPELConsole

For monitoring purposes it's a good practice to set the BPEL Instance title with an unique and descriptive meaning. For example: for order and invoice messages you might want to see the orderNumber in the instance title, like OrderNumber - [orderNumber].

To achieve this use the following code in the BPEL process:
<variable name="Title" type="xsd:string"/>
and
<assign name="GetTitle">
 <copy>
  <from expression="concat('OrderNumber - ',bpws:getVariableData('InputMessage','InputPart','/msg:rootElement/msg:orderNumber'))"/>
  <to variable="Title"/>
 </copy>
</assign>
<bpelx:exec name="SetTitle" language="java" version="1.5">
 <![CDATA[setTitle((String)getVariableData("Title"));]]>
</bpelx:exec>


Next it might be useful to search for all instances related to this ordernumber, for this a small fix is needed to automatically search with wildcards in the BPELConsole Instances:
Modify the following file: $SOA_HOME/j2ee/oc4j_soa/applications/orabpel/console/ngInstanceList.jsp
Replace
// construct where condition step 4: instanceTitle
//
String instanceTitleQ = request.getParameter( "instanceTitle" );
if ( instanceTitleQ != null && instanceTitleQ.length( ) != 0 )
{
  buf.setLength( 0 );
  tmpWhere.setClause( buf.append( n++ > 0 ? " AND " : "" )
    .append( SQLDefs.AL_ci_title )
    .append( " = ? " )
    .toString() );
  tmpWhere.setString( 1, instanceTitleQ );
  where.append( tmpWhere );
}


with

// construct where condition step 4: instanceTitle
//
String instanceTitleQ = request.getParameter( "instanceTitle" );
if ( instanceTitleQ != null && instanceTitleQ.length( ) != 0 )
{
  buf.setLength( 0 );
  tmpWhere.setClause( buf.append( n++ > 0 ? " AND " : "" )
    .append( SQLDefs.AL_ci_title )
//Start search with wildcards
//    .append( " = ? " )
//    .toString() );
//  tmpWhere.setString( 1, instanceTitleQ );
    .append( " LIKE ? " )
    .toString() );
  String wildcard = "%";
  instanceTitleQ = wildcard.concat(instanceTitleQ.concat(wildcard));
  tmpWhere.setString( 1, instanceTitleQ );
//End search with wildcards
  where.append( tmpWhere );
}


Now you can search by the ordernumber in the 'title'-field and the BPELConsole returns all instances with this number somewhere in the instance title.

No comments:

Post a Comment