Event Preprocessors
Event preprocessors are rule functions with one argument of type simple event.
Event preprocessors are not used for time or advisory events, and they are multithreaded.
An event preprocessor is assigned to a destination and acts on all events arriving at that destination. Event preprocessors perform tasks after an incoming message arrives at the destination and is transformed into a simple event, but before it is asserted into the Rete network (if it is — events can be consumed in the event preprocessor).
- If you are using Cache Only mode, take care when designing rules that execute as a result of a time event. For example, a rule that has a join condition using a time event and a concept would not execute if the concept is not loaded in the Rete network and so should not be used in an event preprocessor if the concept is configured as Cache Only mode.
- Events consumed in a preprocessor are acknowledged immediately (and not after the post RTC phase).
You can aggregate events, edit events, and perform other kinds of event enrichment in a preprocessor. You can also use preprocessors as explained below.
You must set locks in the preprocessor when concurrency features are used to protect concept instances during RTC. Locking ensures that updates to concept instances during an RTC do not conflict with another set of updates to the same concept instances in another RTC. Locks are released at the end of the RTC.
If you are using the Cache Only mode for any entities, you must also load the relevant entities from the cache using an event preprocessor.
You can also use preprocessors to improve performance by avoiding unnecessary RTCs in the inference engine. For example you can consume events that are not needed. Another way to use the preprocessor for efficient processing is to transfer an event’s contents to a new concept that is not processed by the agent's set of locally active rules. Such a concept is automatically asserted, and does not trigger rules. It is saved into the cache (depending on OM configuration) where it is available for processing by any agent as needed.