Rules can manage the event cache by removing events (discarding). It is common to use an event only once. For example, once an alarm has triggered a rule that handles the appropriate response, there is no point in keeping this event object in memory. However, in other cases, even after the event is used, it is better to keep it in the event cache, as it could be used later by some rule in order to correlate it with some more recent event. The following rule removes an event after using it.
rule clean_up
activated by EVT of overload::
then {
sendMail(...EVT...);
discard(EVT);
}
The rule detects events of type overload, and uses them for some action (In this example, sending an e-mail). After doing so, it removes the event from the cache. More than one event variable can be given in the argument of discard(), for example, discard(EVT1, EVT2). Use the discard() predefined rule action mostly to remove events generated by rules (internal events), or generated from a third party source. Events generated from BP Server on the execution of process instances are preferably removed from the internal and external caches using the DiscardIndexEntry() or DiscardAllIndexEntry() rule actions.
Note: As mentioned in Operationalsemantics of rules, events are not discarded immediately (that is, while executing the rule), in order to avoid undesirable side effects.