XPath式でのトランザクションの分割
XPath式を使用したビジネストランザクションの命名または分割に使用するXMLペイロード内の値にアクセスできます。Consider the following example from an XMLが3つのアイテムの注文を表している、次のEcommerce注文トランザクションの例を考えてみます。この注文では、次のボディの特徴的な要素であるクレジットカード処理を使用しています。
<acme>
<order>
<type>creditcard</type>
<item>Item1</item>
<item>Item2</item>
<item>Item3</item>
</order>
</acme>
URLは、以下のようになります。
http://acmeonline.com/store
doPost()
public void doPost(HttpServletRequest req, HttpServletResponse resp) {
DocumentBuilderFactory docFactory =
DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Document doc = docBuilder.parse(req.getInputStream());
Element element = doc.getDocumentElement();
//read the type of order
//read all the items
processOrder(orderType,items)
...
}
注文のタイプに応じて、「注文」トランザクションを区別するとします。XPath expression //order/type creditcard を使用できます
- [Rule Configuration] タブで、[Split transactions using XML/JSON Payload or a Java method invocation] をクリックします。
- [Split Mechanism] に [XPath Expressions] を選択します。
- 命名に使用する XML エレメントの値を指す XPath 式を入力します。この例では、
//order/type
エージェントは、 のように、XPath 式の値をビジネストランザクションの名前に追加します。
1 つ以上の XPath 式を使ってビジネストランザクション用に生成された名前を連鎖することができます。
この式が値に評価されない場合、リクエストによってトランザクションが分割されるかどうかを指定できます。