The importance of lifecycle and state

State is cached for agents and the entities that are bound to these agents. State is required to properly evaluate business logic over time.

Rule agents typically accumulate implementation state in the working memory as a by-product of the rules that define the business policy. Rules that test for the existence of something over a time period require that the agent maintains the state of objects so that they can evaluate their conditions correctly. The state is automatically garbage collected based on the semantics of the rules and the time-windows that are defined in the rule conditions. If rules use open-ended time-windows, your administrator is likely to want to limit the amount of state that is maintained to prevent eventual out of memory issues.

Agents that are bound to an entity route the events to the partition that hosts the entity. The lifecycle of the agent is determined by the lifecycle of the bound entity. In other words, deleting the entity deletes all agents that are bound to the entity. It is also possible to define agents that process incoming events that are not bound to an entity. These agents are bound to an empty system entity. The system entity is cached in any partition, and its processed events must be routed consistently to it. All agents adhere to the same lifecycle considerations as entity bound agents.

An entity is created (added to the system) in the following ways:

An entity is deleted (removed from the system) in the following ways:

REST can be used to create and delete entities during development, and for testing purposes. It is assumed that in most scenarios there are events that represent the creation and deletion of an entity in the real-world. Upon receipt of these events, an agent creates or deletes the corresponding entity within the system. For example, in a banking scenario an Account Opening Event and an Account Closure Event govern the lifecycle of an Account entity. An agent registers to receive both these events and either creates or deletes the bound Account entity when the incoming event occurs.