Skip to end of metadata
Go to start of metadata

Example Configuration for a JSON Payload

The following illustration shows a JSON payload posted to a Servlet and the Servlet unmarshalls the payload.

The JSON contains the naming information for the transactions.

For example, the following JSON payload posts an "order" for an item "car" and uses creditcard for processing the order.
The URL is:

*http://acmeonline.com/store*

order
:{
type:creditcard,
id:123,
name:Car,
price:23
}}

The following code snippet shows the doPost method of the Servlet:

public void doPost(HttpServletRequest req, HttpServletResponse resp)

{

//create JSONObject from servlet input stream

String orderType = jsonObject.get("type");\\

//read the item for the order\\

processOrder(orderType,item)\\

.....\\

}

After the posted JSON payload is unmarshalled to the JSON object, the "type" key is required to identify the type of the order. In this case, this key uniquely identifies the business transaction.

To configure this rule:

1. Go to the custom rule section for Servlet Entry Points.

2. Under "Transaction Match Criteria" specify the URI.

3. Under "Split Transactions Using Payloads", enable "Split transactions using XML/JSON Payload or a Java method invocation".

4. Select the split mechanism as "JSON".

5. Enter the JSON object key.

The following screenshot displays the configuration for a custom match rule that will name all the qualifying requests into a single transaction called "Store.Order.creditcard".

6. Set the property "enable-json-bci-rules" to "true" for each node to enable this custom rule. See App Agent Node Properties.

This configuration ensures that the JSONObject and the get("$JSON_Object_Key") method on this object are intercepted automatically to get the name of the transaction. Although the transaction name is not obtained until the JSON object is unmarshalled, the response time for the transaction will be calculated from the doGet method.

Learn More