IBM Integration Bus, Version 9.0.0.5 Operating Systems: AIX, HP-Itanium, Linux, Solaris, Windows, z/OS

See information about the latest product version

References & navigating the message tree

Navigation is the process of accessing elements in the message tree. You can access them in the Compute, JavaCompute, .NETCompute, PHPCompute, and Mappingnodes. The cost of accessing elements is not always apparent and is difficult to separate from other processing costs.

The path to elements is not cached from one statement to another. Consider the following ESQL statement:
SET Description = InputBody.Level1.Level2.Level3.Description.Line[1];
When using the following message:
<Level1>
    <Level2>
        <Level3>
            <Description>
                <Line>1</Line>
            </Description>
        </Level3>
    </Level2>
</Level1>
The broker runtime accesses the message tree, starting at the correlation Root, and then moves down the tree to Level1, then Level2, then Level3, then Description, and finally it finds the first instance of the Line array. If you have this same statement in the next line of your ESQL module, then the same navigation takes place all over again. There is no cache to the last referenced element in the message tree because the access to the tree is intended to be dynamic to take account of the fact that it might change structure from one statement to another. This behavior can lead to repeated sets of navigation and traversing through the elements in a tree. If it is a large message tree, then the cost of navigation can become significant, leading to poor efficiency of your code.

Therefore, to reduce the memory usage of tree navigation, it is recommended that you use a reference variable (for ESQL) or reference pointers (for Java™). Use this technique to save a pointer to a specific place in the message tree, and move it from one field to next as needed.

For example, you can use reference variables to refer to long correlation names such as InputRoot.XMLNSC.Level1.Level2.Level3.Description. Declare a reference pointer as shown in the following example:
DECLARE refDescPtr REFERENCE TO InputRoot.XMLNSC.Level1.Level2.Level3.Description;
Use the correlation name refDescPtr.Line to access the element Line of the message tree.

Use REFERENCE and MOVE statements to reduce the amount of navigation within the message tree and improve performance. This technique can be useful when you are constructing many SET or CREATE statements: Rather than navigating to the same branch in the tree, you can use a REFERENCE variable to establish a pointer to the branch and then use the MOVE statement to process one field at a time.

You have multiple reference variables that are defined within a flow. In the previous example, if your code needed to access fields at Level2 InputRoot.XMLNSC.Level1.Level2 and Level3 InputRoot.XMLNSC.Level1.Level2.Level3 for example, you would define a reference to Level2 and a reference to Level3 as shown in the following example:
DECLARE refToLevel2 REFERENCE TO InputRoot.XMLNSC.Level1.Level2;
DECLARE refToLevel3 REFERENCE TO refToLevel2.Level3;
The following example shows the ESQL that you can use to reduce the number of times that you navigate when you create new output message tree fields:
SET OutputRoot.XMLNSC.Level1.Level2.Level3.Description.Line[1]='1';
DECLARE outRef REFERENCE TO OutputRoot.XMLNSC.Level1.Level2.Level3.Description;
SET outRef.Line2 = '2';
SET outRef.Line3 = '3';
SET outRef.Line4 = '4';
SET outRef.Line5 = '5';
When you reference repeating input message tree fields, you can use the following ESQL:
DECLARE myChar CHAR;
DECLARE inputRef REFERENCE TO InputRoot.XMLNSC.Level1.Level2.Level3.Descritpion.Line[1];
WHILE LASTMOVE(inputRef) DO
        SET myChar = inputRef;
        MOVE inputRef NEXTSIBLING NAME 'Line';  --Repearing record
END WHILE;

In summary, use reference variables or reference pointers to avoid repeated traversing and referencing of the elements that are caused by loops and other ineffective tree navigation.


bj60042_.htm | 
        
        Last updated:
        
        Last updated: 2016-08-12 11:20:23