Version: 17.07
Supported Since: 17.01
Add Variable processing element can be used to add a scope variable of given type, with given key and with given value to the message context. It is possible either to define a specific value for this variable or to extract the value from a message header or a message property.
Any variable added using this processing element will only be added to the current scope of the message context and will be automatically removed when the message context goes out of that scope.
Since this processing element belongs to the set of basic processing elements, this will be available for every project by default. |
Next |
The processing element will add the specified scope variable to the message context and it will be forwarded to this outport |
On Exception |
The message context will be sent to this outport if any exception occurred while adding the scope variable |
Variable Name * |
Basic |
Name of the variable to be added. This variable name is used when retrieving the value of the variable or when removing the variable. If a variable with the same name already exists, its value will be replaced with the new value. |
Extraction Type * |
Basic |
Defines how the value for the variable should be extracted.
|
Value * |
Basic |
Depending on the selected Extraction Type, the definition of this parameter varies.
|
Variable Type * |
Basic |
In the case of NO_EXTRACTION, this parameter should define the type of the scope variable to be set. In other extraction types, this value will be ignored. |
In the following use case, the requirement is to read a message with an XML payload from a JMS queue, validate the payload against an XSD, perform some custom processing based on the result of the validation and finally deliver the message to another JMS queue.
The challenge is to make the custom processing element aware of whether the XSD validation is successful or not.
In this flow, two Add Variable processing elements (shown as No. 1 & 2) has been added to both "On Successful Validation" outport and "On Failed Validation" outport of the XSD Validator.
The 1st Add Variable element (which will receive the message context only if the validation is successful)
adds a boolean
variable with a key, VALIDATION_SUCCESS and a value, true
to the message context.
Similarly, the 2nd Add Variable element (which will receive the message context
only if the validation is failed) adds a boolean
variable with a key, VALIDATION_SUCCESS and a value, false
to the
message context.
Then custom processing element can look at the value of this variable and determine whether the XSD validation has been successful or not.