Process variables are data structures available to the activities in the orchestration process. Process variables can be used to hold data for incoming or outgoing messages as well as maintain the state of the orchestration process as it is executed. Process variables are defined and behave in the same way as TIBCO ActiveMatrix BusinessWorks process variables.
You can define your own process variables and assign values to them in your process definition. Process variables are defined on the Process Variables tab of the
Orchestration Process resource or within a group. You create a process variable in the same way you create data schemas. See
TIBCO ActiveMatrix BusinessWorks Process Design Guide for more information about creating data schemas.
Figure 20 illustrates creating a process variable. You add a process variable and give it a name in the left-most panel, then you create its schema in the middle panel.
Process variables are available to activities within the scope in which the variables are defined. Process variables can be defined at the top-level orchestration process, and these variables are available to all activities within the process. Process variables can also be defined within the scope of a particular group. Process variables defined within a group are only available to activities and nested groups within the group where the variables are defined.
You can assign a value to a user-defined process variable either by using the Assign activity or by configuring an activity to place its output into the variable.
Input and Output of Activities discusses setting a variable using activity output configuration. This section describes the Assign activity.
The Assign activity can copy data from one process variable to another and the activity can be used to modify the value of the data before assigning it to a variable. The Assign activity can only copy or modify data, it cannot change the structure of the data. The Assign activity can include multiple assign statements, and each statement can assign values to different variables.
To use the Assign activity, you create an assign statement, then specify a source of data in the Assign From field. The Assign From field allows you to specify an XPath expression to select the data from one or more existing process variables. You can also use functions in the expression to modify the data as needed or you can obtain data from a function, such as the current time of day.
After specifying the Assign From field, you specify the target location to store the data in the Assign To field. For process variables of simple types, you can assign a value to the process variable and instantiate it in one statement. For more complex variables, you can use multiple assign statements to assign values to each field within an already instantiated process variable.
The Assign From expression must evaluate to the same datatype as the expression in the Assign To field. You cannot create a new variable by only providing some of the fields of a complex datatype in the Assign From field. You must first create a new instance of the variable by copying from a compatible data structure, then you can reassign values to particular fields in subsequent assign statements.
Figure 21 illustrates updating the value of a field within an existing process variable with a constant value. The
$Receive-Starter process variable is used to hold the output of the Receive activity that accepts a new loan request. The loan request contains a requestor ID, the loan amount, and a field named CreditOK to hold status of the credit check. The illustrated Assign activity is assigning the value "No" to the CreditOK field.
The Assign activity can instantiate variables that are specified as XML Element References to simple datatypes, such as decimal, integer, or string. This is useful for storing simple values in process variables such as counters, constants, or running calculations. For example,
Figure 22 illustrates a process variable named
$OfferPrice with one element that is an XML Element Reference to an XSD element named
Price.
The Assign activity can instantiate this variable in one statement by assigning a value to the variable.
Figure 23 illustrates instantiating
$OfferPrice/Price by assigning the constant "500" to the variable.
See Assign for more information about how to set the fields in the Assign activity.
Some activities produce output. Activities have access to any data that is output from previously executed activities in the process definition. An activity’s output is placed into a process variable with the same name as the activity. You can also optionally specify a user-defined variable to hold the contents of an activity’s output.
$_globalVariables contains the list of global variables defined on the Global Variables tab of the project. See
TIBCO ActiveMatrix BusinessWorks Process Design Guide for more information about global variables.
$_processContext contains general information about the process, such as the process ID, the project name,whether the process was restarted from a checkpoint, and so on.
TIBCO ActiveMatrix BusinessWorks provides error process variables to contain data pertaining to the error that has occurred. TIBCO ActiveMatrix BusinessWorks BPEL Extension does not have error transitions like TIBCO ActiveMatrix BusinessWorks. Instead, faults must be caught and handled by exception-handling routines. Because a fault contains the information within the error process variable, this type of variable is not as useful to an orchestration process.
See Chapter 6, Exception Handling for more information about handling errors.
All process variables in a running process instance are stored in memory and therefore consume system resources. When variables are no longer referenced by activities in an orchestration process, they are cleaned from memory to free memory for other processing.
The EnableMemorySavingMode property controls whether memory for process variables is cleaned up on a per-process instance or per-engine basis. See
TIBCO ActiveMatrix BusinessWorks Administration for more information about setting properties.