Variable mediator¶
The Variable mediator is used to manage variables within a mediation flow. The Variable mediator allows you to set variables, which can then be used later in the mediation flow.
Syntax¶
<variable name="string" [type="STRING"|"BOOLEAN"|"INTEGER"|"DOUBLE"|"LONG"|"XML"|"JSON"] (value="string" | expression="expression") />
Configuration¶
The parameters available to configure the Variable mediator are as follows:
Parameter Name | Description |
---|---|
Name | The name of the variable. This name uniquely identifies the variable in the mediation flow. |
Data Type | The data type of the variable. Available types are as follows:
|
Value | You can give either a static value or a Synapse expression. |
Examples¶
Set a variable with a static value¶
This example demonstrates setting a variable with a static value.
<variable name="username" value="JohnDoe" type="STRING"/>
Set a variable with an expression¶
This example demonstrates dynamically setting a variable using an expression.
<variable name="userDataObject" expression="${payload.user.data}" type="JSON"/>
<variable name="userId" expression="${payload.user.id}" type="INTEGER"/>