Try OpenEdge Now
skip to main content
BPM Events User's Guide
BPM Events tutorial : Using rules to modify monitoring reports

Using rules to modify monitoring reports

Assume we also want to record the average response time of each request type, for each region. In Business Process Server, a process instance always generates an event of type PI_COMPLETED when it completes, in the same way as it generates a PI_ACTIVATED event when it starts. Let us assume that this completion event also contains the actual duration of the request, in the event attribute named responsetime. The previous monitoring rule is modified by a rule named monitor_timeReq, which is defined as follows:
rule monitor_timeReq
activated by evt1 of BP Server::PI_COMPLETED
{ val stat = ReqStats [evt1.reqtype][ evt1.region];
stat.avgtime ::= avg(toInt(evt1.responsetime), stat.count++, 1);
The rule above is executed each time a BP Server event of type PI_COMPLETED is notified.
Its plain English version is:
"On reception of an event of type BP Server::PI_COMPLETED, add 1 to the count attribute of the corresponding element of the infopad ReqStats, AND update the average response time for this request type and this region."
Now each element (or cell) of the infopad must remember two values:
1. A request count for each request type by region (here automatically updated when using the increment operator ++ in the function avg)
2. The average value of all response times for each request type by region (updated here with the avg() function).
In case you use the rule editor to generate this rule, you see that it generates a slightly different syntax for the action part. A single statement does not use the intermediate variable stat, shown as follows:
{ ReqStats[evt1.reqtype][ evt1.region].avgtime ::= avg(evt1.responsetime,
ReqStats [evt1.reqtype][evt1.region].count++, 1);