Getting values from global aggregates in rules

Use the values of global entity aggregates and global event aggregates in your rules to evaluate conditions and make decisions.

You can use your global event aggregates and global entity aggregates similar to the way you use other rule variables. For example, you can use global aggregates in condition statements and calculations to determine a course of action or whether an event should be emitted.

However, because global aggregates are defined and calculated by a different process than rule variables, you cannot create them in a rule.

For event aggregates, the value of the variable is calculated and updated locally after an event arrives. Because updates occur on all nodes in the system, the value becomes consistent only after the aggregated values are received at every node. At one time, agents on different servers might have different aggregate values.

In the following simplified example, a rule refers to a global event aggregate that has the name TotalAttendedSessionsToday:
if 
	TotalAttendedSessionsToday is more than 10
then
	print "There have been more than 10 sessions today";
The global event aggregate is recalculated every time an event of a session being attended occurs. In this example, when more than ten sessions are attended, some action must be taken. For example, more departure surveys or food vouchers might need to be prepared for the attendees.
In the following simplified example, a rule refers to a global entity aggregate that has the name AverageSessionSize:
if 
	the session size of the session is more than AverageSessionSize
then
	print "The session size is bigger than average";
In this example, when a session size is larger than average, some action must be taken. For example, extra chairs or handouts might need to be placed to accommodate all the attendees.