Using variables in Apigee Integration

You're viewing Apigee X documentation.
View Apigee Edge documentation.

A variable is an integration element that holds and transports data between the tasks, triggers, and edges of an integration. Variables can be statically defined at design time, or dynamically passed to the integration at runtime, or reference other variables in an integration. Variables can be globally accessible to all tasks, or locally accessible to a specific task.

Apigee Integration uses two types of variables:

  • Integration variables keep track of data throughout the course of an entire integration execution.
  • Task variables keep track of data for the duration of a single task.

Integration variables

Integration variables are similar to variables used in the programming languages. Data in the variables can be read and written throughout the execution of the integration.

Integration variables can be used in the following ways:

  • Taken in as inputs to the integration (input variables).
  • Returned as outputs of the integration (output variables).
  • Used to hold temporary state during the execution of an integration.

The value of a variables does not have to be statically defined in the integration. Variable values can be passed into an integration through the use of a trigger. However, if a variable is statically defined in the integration, and the same variable is supplied dynamically with trigger, the dynamic value assignment will overwrite the static assignment.

Format of an integration variable

An integration variable contains the following information:

  • A string name that uniquely identifies the variable in the integration.
  • A data type.
  • Optionally, a variable may contain:
    • A default value, if the variable data type is string, int, or double.
    • Settings relating to actual or sample JSON schema, searchability in logs, etc.

Supported Data Types for integration variables

The following data types are supported for integration variables:

  • String and String array
  • Integer and Integer array
  • Double and Double array
  • Boolean and Boolean array
  • JSON

Task variables

Task variables are pre-defined variables of a task. If a task has an output, all such ouputs are available in a task variable. You cannot delete or edit a task variable. For example, in the Call REST Endpoint task, the response body is stored in the responseBody variable.

Defining variables in integration

The integration designer provides a friendly UI that allows you to define and initialize variables. You can view all the variables of an integration by clicking VAR on integration designer toolbar. The following image shows the Create Variable pane:

create variable configuration pane

Using variable data in integrations

During the execution of an integration, run-time data is passed in as variables that are declared for the integration or task. Once execution begins, input data is converted into an in-memory object called an Event.

After the Event object is created, an in-memory graph of tasks is built using the integration definition. Incoming variable values are passed to tasks based on your configuration. As the integration executes, the tasks read and write data back into the Event object,to be used by subsequent tasks or to form the output data of the integration.

Persisting variable data

During the execution of the integration, the Apigee Integration platform persists variable data periodically to enable retries in the event of failure and to serve the execution Logs for debugging and monitoring purposes. Integration owners can control the persistence of data (or turn it off), by setting the appropriate Persistence policy.