3.4. Data


While the rule flow is designed specifically to allow you to create process control flows, you also have to plan it from a data perspective. Throughout the execution of a process, data is retrieved, stored, passed on and used.
To store run-time data while a process is executing, use variables. A variable is defined by a name and a data type. This could be something very basic, such as Boolean, int, or String, or it could be any kind of Object sub-class.
Define variables inside a variable scope. The top-level scope is that for the process itself. Sub-scopes can be defined via a composite node. Variables that are defined in sub-scopes can only be accessed by nodes within that scope.
Whenever a variable is accessed, the process will search for the appropriate definitive variable scope.
You are allowed to nest variable scopes. A node will always search for a variable in its parent container. If the variable cannot be found, it will look in that one's parent container, and so on, until the process instance itself is reached. If the variable cannot be found, a read access yields null, and a write access produces an error message, with the process continuing its execution.
You can use variables in these ways:
  • you can set process-level variables when starting a process by providing a map of parameters to the invocation of the startProcess method. These parameters are then set as variables on the process scope.
  • actions can access variables directly. They do so by using the name of the variable as a parameter name:
    // call method on the process variable "person"
    person.setAge(10);
    Copy to Clipboard Toggle word wrap
    You can change the value of a variable via the knowledge context:
    kcontext.setVariable(variableName, value);
    Copy to Clipboard Toggle word wrap
  • you can make WorkItem and SubFlow nodes pass the value of parameters to the "outside world" by mapping the variable to one of the work item parameters. To do so, either use a parameter mapping or interpolate it into a String parameter, using #{expression} . You can also copy a WorkItem's output to a variable via a result mapping.
  • various other nodes can also access data. Event nodes, for example, can store the data associated with an event in a variable. Exception handlers can read error data from a specific variable. Check the properties of the different node types for more information.
Finally, every process and rule can access globals. These are globally-defined variables that are considered immutable with regard to rule evaluation and data in the knowledge session.
You can access the knowledge session via the actions in the knowledge context:
kcontext.getKnowledgeRuntime().insert( new Person(...) );
Copy to Clipboard Toggle word wrap
Back to top
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2026 Red Hat