CBR

 

Configuration and Testing. PAGEREF _Toc225228916 \h 2

Schema. PAGEREF _Toc225228917 \h 2

Namespaces. PAGEREF _Toc225228918 \h 3

Routing Rules. PAGEREF _Toc225228919 \h 3

Functional Demonstration. PAGEREF _Toc225228920 \h 6

Scenario 1. PAGEREF _Toc225228921 \h 6

Use Case Scenario. PAGEREF _Toc225228922 \h 7

Useful Tips. PAGEREF _Toc225228923 \h 7

 

CBR (Content Based Routing) is used to route the incoming messages on to different destinations based on the content of the messages.

The component creates a port for each of the XPath expressions specified and the messages satisfying the particular XPath is sent onto the respective port. In addition to these ports an output port OUT_FALSE is created and messages whose content does not satisfy any of the XPath expressions will be sent out of this port. If more than one XPath condition is true, the message is sent on all the ports for which the XPath condition evaluates to true.

Configuration and Testing

The CBR component can be configured using its Custom Property Sheet wizard.

Schema

Figure 1: Provide schema

The schema of the XML content that is used for routing should be provided using the Schema Editor in the Schema panel.  The XML content that is used for routing is detemined by property Apply Xpath on Context in Routing Rules panel.

Refer to Schema Editor section in Common Configurations chapter for information about Schema Editor shown in Figure 1.

Namespaces

Figure 2: List of namespaces

List of namespace prefixes that are used in the XPath and the namespaces they represent are provided in the Namespaces panel. The table in this panel is automatically populated with namespaces defined in XML schema provided in Schema panel.

To remove unnecessary namespaces, select the row containing namespace and click the Delete button.

To add a new namespace prefix and namespace, enter the details in the empty row and press Enter key.

Routing Rules

Figure 3: XPath(s) to be evaluated on the input messages

XPaths based on which the routing is done can be configured in Routing Rules panel.  XPath editor can be used to configure XPaths. Click the ellipsis button in the XPath column to open XPath Editor. Alternatively, a valid XPath expression can be typed directly in the table

An empty row is automatically after closing the XPath Editor or after pressing Enter key after the XPath is manually provided.

Refer to XPath Editor section in Common Configurations chapter for information about XPath Editor shown in Figure 1.

For each configured XPath expression, an output port is created with the name provided in OutPort_Name column, messages satisfying the given XPath condition are routed onto this port. Port names ON_EXCEPTION, OUT_FALSE and ON_TRANSACTION_FAIL are reserved and cannot be set in OutPort_Name column.

Note:

 

Figure 4: Setting runtime argument 'useFioranoCBR'.

Figure 5: XPath processor properties in Routing Rules page

Processor

Specifies the processor used to evaluate XPath conditions. If the number of XPath conditions are more (greater than 4), then XSLT processor is preferable for better performance. If the XPath conditions are less then both processors will give equal performance. XPath processor is preferable if the XPaths are complex. XSLT processor might not work for all XPaths.

XPath

Uses Saxon based XPath evaluator to evaluate XPaths. Values in column XPath should be valid XPath expressions. XPaths are validated if XPath processor is selected. The validation will be done for some simple XPath conditions only. So, if the XPath is validated, there is no guarantee that the XPath results a boolean value. 

XSLT

Uses XSLT to evaluate condition. Values in column XPath can be any valid Boolean condition in XSLT. There is no validation check on XPath conditions if we select XSLT processor.

Note: While using XSLT processor, if XPath contains any functions having namespace prefixes like saxon:parse(), then the appropriate prefix and namespace URL pair should add in the Namespace panel. For example to use saxon functions namespace URL http://saxon.sf.net/ should add to prefix saxon in the Namespace panel.

Example: For a value /ns1:Transaction/ns1:request/ns1:source = 'tserv' provided in column XPath the following XSL is used.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

xmlns:ns1="http://www.incomm.com/transaction/2008-02"

xmlns:ns2="http://www.w3.org/2001/XMLSchema">

 

<xsl:output method="text" encoding="UTF-8"/>

<xsl:template match='/'>

<xsl:if test="/ns1:Transaction/ns1:request/ns1:source ='tserv'">TSERV,</xsl:if>

 

</xsl:template>

</xsl:stylesheet>

Use XPath 1.0 – When this property is selected, XPath 1.0 is used for evaluation. Otherwise, XPath 2.0 is used. This checkbox is visible only when the Processor is selected as XPath.

Apply XPath on Context – When this property is selected, the XPath is evaluated on the Application Context of the input message. Otherwise, XPath is evaluated on Body of the message.

When XPath is evaluated on Context of the message, no schema is set on the ports of CBR. In case of evaluating text body of the message, schema provided earlier in the configuration (if present) will be set on the ports.

Note: When this option is chosen, provide application context schema in the schema panel.

Functional Demonstration

Scenario 1

CBR is configured to filter the messages on the basis of employee age in the input message. It is sent to one of the output ports depending on the XPath specified in the CBR.

Configure the CBR as described in Configuration and Testing section and use feeder and display component to send sample input and check the response respectively.

Figure 6: Demonstrating Scenario 1 with sample input and output

Sample Input:

<ns1:Employee_Schema xmlns:ns1="http://www.fiorano.com/fesb/activity/XML2Text2">

 <ns1:Employee>

<ns1:EmployeeName>anirudh</ns1:EmployeeName>

<ns1:EmployeeID>294</ns1:EmployeeID>

<ns1:EmployeeAge>22</ns1:EmployeeAge>

 </ns1:Employee>

</ns1:Employee_Schema>

Sample Output:

<ns1:Employee_Schema xmlns:ns1="http://www.fiorano.com/fesb/activity/XML2Text2">

 <ns1:Employee>

<ns1:EmployeeName>anirudh</ns1:EmployeeName>

<ns1:EmployeeID>294</ns1:EmployeeID>

<ns1:EmployeeAge>22</ns1:EmployeeAge>

 </ns1:Employee>

</ns1:Employee_Schema>

Use Case Scenario

In Purchasing System sample, a purchase request is sent by the user to a company through a web based interface. The purchase order consists of three inputs namely REQUEST, CREDENTIALS, and SYNC_PO_002. REQUEST is an identifier string for the request. The request identifier is verified by a CBR (Content Based Router) component to be the correct one for which this system is expected to service the request.

Figure 7: Purchasing System sample

Useful Tips

The order of the XPath conditions specified in the CPS does not matter.

The CBR component supports XPath version 1.0 and 2.0. The default is version 2.0. To use version 1.0, please select the checkbox Use XPath 1.0 in the CPS.

To monitor time taken for executing each request, set log level for logger com.fiorano.edbc.cbr.monitor to INFO.

When runtime argument for this component, useFioranoCBR is set to yes, please make sure that the XPaths provided in the configuration are valid JMS Message. More information on JMS Message Selectors can be found in the documentation for Message interface in JMS APIs.  http://java.sun.com/products/jms/javadoc-102a/index.html.

To apply XPath on context check Apply XPath on Context in Routing rules panel and provide Application context schema in the schema panel. In this case schema will not be set on output ports.

 

TOP

Copyright © 1999-2008, Fiorano Software Technologies Pvt. Ltd. All rights reserved.

Copyright © 2008-2009, Fiorano Software Pty. Ltd. All rights reserved.

This software is the confidential and proprietary information of Fiorano Software ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only in accordance with the terms of the license agreement enclosed with this product or entered into with Fiorano.