Effect of Time on Cache Queries

While running continuous queries, errors can occur if entity creation and deletion happen in rapid succession.

Example

Consider a continuous query that is monitoring entities of type /OrderEvents. Suppose that OrderEvents entities are created, asserted, and consumed, at a fast rate. When an OrderEvent entity is asserted, it is also added to the cache. When it is consumed, an OrderEvent entity is deleted from the cache. The continuous query receives the creation notification and the deletion notification one after the other.

If there is a long enough delay between the creation and deletion actions and the moment a query agent attempts to process the related notifications, the agent will try to retrieve OrderEvent entities that have already been removed from the cache, resulting in runtime errors.

This situation may occur when, for example, a very quick succession of notifications is sent, or the network traffic suffers delays, and so on.

Query Agent Local Cache

The query agent retains the most recently processed entities in a local cache to avoid frequent network lookups. But in the earlier example, the OrderEvent is deleted from the cache even before the create-notification is processed by the query, so the Orderevent cannot be copied into the query agent's private cache.

Keep such situations in mind as you design your queries.