Using scratchpad areas in the local environment

The local environment tree includes a subtree called variables. This subtree is always created, but is never populated by the message flow. Use this area for your own purposes; for example, to pass information from one node to another. You can create other subtrees of the local environment tree.

About this task

The advantage of creating your own data in a scratchpad in the local environment is that this data can be propagated as part of the logical tree to subsequent nodes in the message flow. If you create a new output message in a Compute node, you can also include all or part of the local environment tree from the input message in the new output message.

To ensure that the information in the local environment is propagated further down the flow, the Compute mode property of the Compute node must be set to include the local environment as part of the output tree (for example, specify LocalEnvironment and Message). For further details about the Compute mode property, see Setting the mode.

However, any data updates or additions that you make in one node are not retained if the message moves backwards through the message flow (for example, if an exception is thrown). If you create your own data, and want that data to be preserved throughout the message flow, you must use the environment tree.

You can set values in the variables subtree in a Compute node and those values can be used later by another node (Compute, Database, or Filter) for some purpose that you determine when you configure the message flow.

The local environment is not in scope in a Compute node, therefore you must use InputLocalEnvironment and OutputLocalEnvironment instead. For example, you might use the scratchpad in the local environment to propagate the destination of an output message to subsequent nodes in a message flow. Your first Compute node determines that the output messages from this message flow must go to WebSphere® MQ queues. Include the following ESQL to insert this information into the local environment by setting the value of OutputLocation in the OutputLocalEnvironment:
SET OutputLocalEnvironment.Variables.OutputLocation = 'MQ';
Your second Compute node can access this information from its input message. In the ESQL in this node, use the correlation name InputLocalEnvironment to identify the local environment tree in the input message that contains this data. The following ESQL sets queueManagerName and queueName based on the content of OutputLocation in the local environment, by using InputLocalEnvironment:
IF InputLocalEnvironment.Variables.OutputLocation = 'MQ' THEN
   SET OutputLocalEnvironment.Destination.MQ.DestinationData.queueManagerName = 'myQManagerName';
   SET OutputLocalEnvironment.Destination.MQ.DestinationData.queueName = 'myQueueName';
END IF;

In the example, queueManagerName and queueName are set for the Destination subtree in the output message. You must set the Compute mode of the second Compute node to include the local environment tree in the output message. Configure the MQOutput node to use the destination list that you have created in the local environment tree by setting the Destination Mode property to Destination List.

For information about the full list of elements in the DestinationData subtree, see Data types for elements in the MQ DestinationData subtree.