Ce contenu n'est pas disponible dans la langue sélectionnée.

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
Red Hat logoGithubredditYoutubeTwitter

Apprendre

Essayez, achetez et vendez

Communautés

À propos de la documentation Red Hat

Nous aidons les utilisateurs de Red Hat à innover et à atteindre leurs objectifs grâce à nos produits et services avec un contenu auquel ils peuvent faire confiance. Découvrez nos récentes mises à jour.

Rendre l’open source plus inclusif

Red Hat s'engage à remplacer le langage problématique dans notre code, notre documentation et nos propriétés Web. Pour plus de détails, consultez le Blog Red Hat.

À propos de Red Hat

Nous proposons des solutions renforcées qui facilitent le travail des entreprises sur plusieurs plates-formes et environnements, du centre de données central à la périphérie du réseau.

Theme

© 2026 Red Hat
Retour au début