Skip to content

Configure event queues in Cratis Chronicle Server

The events section controls how Chronicle delivers appended events to observers and retains event-sequence state and causation properties. Use it to tune burst handling or reduce persisted audit metadata without changing your application’s event types.

Put these settings at the root of chronicle.json, not inside a Cratis or Chronicle wrapper. The following example shows the defaults:

{
"events": {
"queues": 2,
"queueBoundedCapacity": 2000,
"queueBoundedEvents": 5000,
"statePersistenceInterval": 1000,
"constraintsVersionCheckInterval": "00:00:01",
"causationPropertyRetention": "Retain",
"queueDepletionWaitTimeoutMilliseconds": 500
}
}
Setting Default Meaning
queues 2 Number of appended-event queues per event sequence. Each queue routes appended events to the observers assigned to it. See How observers use the queues.
queueBoundedCapacity 2000 Capacity in batches, not individual events, of each queue and of each observer’s backlog within it. 0 makes both unbounded.
queueBoundedEvents 5000 Most events a queue, or one observer’s backlog within it, may hold before spilling to catch-up. Bounds memory when batches are large. 0 makes it unbounded.
statePersistenceInterval 1000 Appends between warm-start state snapshots. State is also persisted on the first append after activation and on deactivation.
constraintsVersionCheckInterval 00:00:01 Maximum frequency of constraint-version polling during appends. A zero interval checks on every append.
causationPropertyRetention Retain Retain or Omit. See Causation property retention.
queueDepletionWaitTimeoutMilliseconds 500 Bounds the final queue-empty wait when awaiting depletion outside a debugger.

The state snapshot interval does not determine sequence-number correctness: activation can rebuild state from the event tail.

Every reactor, reducer, projection and other observer of an event sequence is assigned to one of its queues by a stable hash of the observer’s id. The same id always lands on the same queue, across restarts, for a given queues value. When events are appended, each queue passes them to the observers assigned to it that subscribe to them. This is live delivery only; catch-up and replay read from the event log and do not go through the queues.

Within a queue, every observer has its own backlog and receives its events at its own pace. A reactor waiting on a slow downstream service holds back only itself. A reducer or projection assigned to the same queue keeps handling new events as they arrive. Each observer gets its events in sequence order, one event source at a time. When it has fallen behind, its backlog is delivered in fewer, larger calls.

Appends never wait for observers:

  • When one observer’s backlog exceeds queueBoundedCapacity batches, that observer alone stops receiving live events and spills to catch-up. Catch-up rereads what it missed from its persisted cursor, and the observer subscribes again once it has caught up. The other observers on the queue are not affected.
  • When a single pass of an observer’s backlog would need more than 256 sequential per-partition deliveries, the observer spills to catch-up the same way. Bulk appends that interleave many event sources are then processed in parallel per partition instead of one event at a time.
  • When a queue itself fills, in batches or in events (queueBoundedEvents), only the observers the rejected batch was meant for spill to catch-up the same way. Observers subscribed to other event types stay live.

Increase queueBoundedCapacity to absorb longer bursts. A smaller value moves a lagging observer to catch-up sooner.

More queues spread the routing of appended events over more processing loops, which helps when many observers share an event sequence. More queues are not needed to keep a slow observer from delaying others.

An observer handles one event source’s run of consecutive events per call, and its calls happen one after the other. Its throughput therefore depends on how the events arrive more than on how many there are:

  • Events for the same event source appended together reach the observer in one call.
  • Events from many event sources interleaved in the log reach it in one call each.

The cost of a call is mostly the round trip to the client and the observer’s own progress write. When a burst interleaves many event sources, an observer handles far fewer events per second than when the same number of events arrives grouped by event source.

causationPropertyRetention accepts Retain or Omit. Omit preserves each causation entry’s type and time but writes an empty properties dictionary for newly persisted events. It does not rewrite historical events or remove personal data from event payloads.

To override only this setting through the environment, use Cratis__Chronicle__Events__CausationPropertyRetention=Omit.