Global aggregates in Java agents

Use the values of global entity aggregates and global event aggregates in Java™ agents to evaluate conditions and make decisions.

After you define a global entity aggregate or global event aggregate in a .agg file, you can access the variable by using the AgentGlobalRuntime.getGlobalValue method in your Java code.

Example:
// to get the value of a global aggregate called entityValue.  The name is defined in the variable set.  The type of object returned is Double

Object entityValue = getGlobalValue("defvarMaxSessionSize");

The value that the getGlobalValue method returns is the same for the entire time the Java agent runs in response to an event. Therefore, if you call the getValue method multiple times, the same value is returned each time.

You can also submit a job to update the value of an aggregate. The following example code fragment submits a global entity aggregate job by using the service.submitJob method:
// to submit a job.  com.ibm.ia.global.jobs was added to the list of imported packages in the manifest and an import statement from JobService and JobException was added

try
{
       JobService service = getJobService();
       service.submitJob("defvarMaxSessionSize");
}
catch (JobException jexc)
{
       jexc.printStackTrace();
}

The job is submitted asynchronously and is started in the background. Submitted jobs are queued and if the agent is processing an event, the job starts after the agent processing finishes.