Try OpenEdge Now
skip to main content
BPM Events User's Guide
Recovery of global variables and file handling : Recovering global variables

Recovering global variables

The only data objects that are fully recoverable are infopads. It is possible to use an infopad for storing the value of a global variable, so that it will be recovered. In the example below, the variable x is supposed to be initialized to 0 when the module is initially loaded, but is initialized to some infopad value when recovering. This infopad value holds the value of the variable when BPM Events is shutdown.
application BP_test_suites
module test_util
var persist_x = new infopad<cell{xval:int}>[1][1]("persist_x");
var xval = 0;
fun x_init(){ xval := persist_x[1][1].xval; return xval; }
var x = (is_recovery_mode())? x_init(): 0;
The predefined boolean function is_recovery_mode() returns true if the initialization statement is executed in the context of a recovery, and false if executed when loading the module in a normal way. In order to make sure the infopad persist_x always stores the latest value of x, it must update each time x is updated in a rule (an assignment statement at the end of the action part of the rule is sufficient: persist_x[1][1].xval := x;).