3.1 Function Blocks

Use the following functions blocks in the Aggregation agent for general processing:

  • initialize in Batch and Real-Time

  • deinitialize in Batch and Real-Time

  • drain only in Batch

  • beginBatch only in Batch

  • endBatch only in Batch

  • cancelBatch only in Batch

  • commit only in Batch

  • rollback only in Batch
     

Note!

The session variable is not available within the function blocks listed above. For more information about these function blocks, see 1.4 Function Blocks.


Use the following function blocks, in which the session variable is available, for Aggregation specific functions.

  • consume in Batch and Real-Time
  • command only in Real-time
  • sessionInit in Batch and Real-Time
  • timeout in Batch and Real-Time


consume - Batch and Real-Time

The consume block is called each time a UDR that matches a session, or causes a new session to be created, arrives. Thus, the consume block is not necessarily called for each arriving UDR. The UDR will be available through the input variable and the session through the session variable.


command - Real-Time Only

The command block is called for all flushed sessions. The flush action is initiated with an Agent Command from the Command Tab of the Aggregation agent in the Workflow Monitor or through the Command Line Tool mzsh. Within this block the instruction variable is available and contains a string, optionally forwarded by the user. For further information, see 3.5 Flush Sessions and 3.2 Variables.


sessionInit - Batch and Real-Time

The sessionInit block is called each time a new session is created. The UDR that caused the session to be created will be available through the input variable and the new session through the session variable. The sessionInit block is optional. It is, however, recommended that you use this block since it makes the code easier to follow.


timeout - Batch and Real-Time

The timeout block handles sessions that for some reason have been left hanging in the system. For instance, if the stop UDR was not received within a timeout interval.

Between drain and endBatch for each batch passing the Aggregation agent (batch workflow) or as defined in the agent configuration (real-time workflow), the timeout block is called for all outdated sessions. The outdated session will be available through the session variable.

Initially, make sure the code in the timeout block handles the session properly, then there are two alternatives on how to handle the session:

  • If the session is not needed anymore, remove the session with sessionRemove.
  • If relevant UDRs are still expected, set a new timeout with sessionTimeout.

If none of them are used, outdated sessions that may never be used again will remain in the system forever and will always be active for comparison against incoming data, which will have a negative impact on performance.

If there are old sessions with no timeout set, correct the timeout block and then open the Aggregation Session Inspector. If there is no use for the sessions, they may be deleted, otherwise set a new timeout for these sessions and they will be handled by the timeout block as soon as a new batch is processed by the Aggregation agent.