In this section: How to: |
A variable is a named place where a value can be stored. Variables can participate in comparisons and may be used in arithmetic or string expressions. A Designer variable can be a special register, a constant, or an XPath expression on the processed document.
Some variables are provided by the system. These variables, called special registers, hold information that you might need in your process flow. For example, the special register IP holds the source IP address of a message that arrives through an IP protocol, such as TCP or HTTP. You can refer to these built-in variables by the special register function, SREG().
Run-time variables are evaluated and substituted each time the process flow runs. A run-time variable can be one of two usage types; ‘header’, which indicates the variable is part of the document routing information (such as, an HTTP header or an IBM MQSeries descriptor) or ‘user’, which indicates all other variables.
Design-time variables are evaluated and substituted when the process flow is compiled. Design-time variable names begin with a dollar sign ($). Once in a run-time environment, these variables do not change. For example, a design-time variable named $CompanyName is assigned the value of ‘Acme’ and the process flow is compiled. When you run this process flow, Acme will always be used as the value for $CompanyName. To change this variable, you must change the value in the design-time environment and recompile the process flow.
The following procedure explains how to create a run-time variable and also incorporates information on creating a design-time variable.
To create a run-time variable:
The Property Manager dialog box opens displaying the Design Time tab, which exposes the design-time properties, as shown in the following image.
The design-time variable properties are Name, Type, Value, and Description.
The run-time variable properties are Name, Type, Value, Usage, Scope, and Description.
The fields under each column of the Property Manager dialog box are activated, as shown in the following image.
The variable type options are:
string. Text, such as "The quick brown fox".
integer. A positive or negative whole number, such as 12 or -3.
boolean. A '0' (false) or a '1' (true).
decimal. A number in decimal notation, such as 3.141.
duration. A time interval in ISO standard form.
password. A string, the value of which is hidden when entered.
Note: The default usage in Designer is user.
The following special registers are available in the Property Manager:
[iwayversion], [iwayhome], [engine], [iwayconfig], and [locale]
Note: To select a variable to work with while in the Property Manager window, use the up and down arrow icons in the upper-right corner. Use the red X next to the arrow icons to delete a variable.
The Add or Remove Registers dialog box opens, as shown in the following image.
The variable is now available as a selection when configuring objects in a process flow.
A variable can be used as content in the data or in header information, and it can also be used to affect the run‑time logic behavior of a process flow. The following object can be used in conjunction with Designer variables to change a flow’s logic:
For more detailed information on objects, see Defining Objects in a Process Flow.
All but the simplest flows have multiple paths. Each distinct path through a flow is either an alternate path or parallel path:
New paths are created when more than one relationship line exists for an object. For example, if you deploy a Decision Test object in your flow, it will return either ‘true’ or ‘false’. The paths for ‘true’ and ‘false’ are alternate paths since the result of the logical test can only be true or false, never both. In contrast, if you create two lines for the ‘true’ state, the two paths created will execute in parallel.
OnCompletion relationships always execute in parallel to either the 'true' or 'false' relationships. If you have just one 'true' and one 'false' relationship, then these will always be alternate paths.
The Join and Junction objects are related to the concept of parallel and alternate paths. A Join object acts as a rendezvous point for parallel paths. Once all the paths coming into the Join have fired, the Join action is taken. The output of a Join object is a document that is the result of merging the documents received on each of its inbound paths.
The Junction object allows alternate paths to rejoin for common processing.
Scope
Flow- and message‑scoped variables have one shared copy for the entire flow, therefore, a change made to the variable will be seen on all parallel paths. Unless various points of the parallel flows are synchronized, the results written to a global variable may leave the variable with an unpredictable value.
Flow-scoped variables are deleted at the termination of the process flow (or sub-flow) in which they are declared. If you need a variable to be available to the calling flow (parent flow) or to subsequent components, such as outlets and emitters, choose message as the scope.
Thread-scoped variables are duplicated for each parallel document path, allowing independent manipulation of each copy. After parallel paths converge at a Join object, the value of the thread is undefined.
Note: It is your responsibility to keep track of parallel and alternative flows and the differently scoped variables. The system will not do this for you.
Pre- and Post-Execution
Often it is necessary to save a value from the processed document before sending it into an Execution object in order to reuse that value later in the process flow. Each Execution object has an implicit facility to assign values to one or more run-time variables prior to or after execution. From the Pre-Execution of Post-Execution tabs, you can choose a variable to set, or launch the Property Manager to create a new variable. Assigning variables through these tabs provides an alternative to using Set objects in a process flow. Since both methods perform the same function, you can use the Pre- and Post‑Execution method rather than numerous Set objects to create an uncluttered process flow diagram.
The following image is an example of a Pre‑Execution tab in a Service object Properties dialog box that shows the variable selections from the Name drop-down list.
Note: Since design-time variables are substituted within the Designer at compile time, only run-time variables are permitted as targets of Pre- and Post-Execution assignment.
iWay Software |