Every fact has a role. It’s fact by default or is specified by @role annotation:

@role( <fact | event>)

for example:

declare StockTick
    @role( event )
    ...
end

Role defines how the engine should handle instances of that type: either as regular facts or as events.

  • event : declares that the type is to be handled as an event. Which means that type will have managed lifecycle.

    Facts coming from Amazon Kinesis must be declared as events.

  • fact: this is the default, declares that the type is to be handled as a regular fact.


Why all this is important?

There are 2 types of data:

  1. streaming, like that coming from Kinesys (events)
  2. static or slow changing - reference data, like that coming from DynamoDB (regular facts)

Static data is loaded to the memory and stays there forever, while streaming data should stay in the memory just for a period when it can possibly match other facts according to its temporal constraints. If the system won’t be able to manage its memory efficiently, it will run out of memory very fast (Kinesis is able to deliver multi MB loads per second and there can be multiple streams).