liveBook · Manning

Sequence number

As explained in Akka in Action, Second Edition

A sequence number is an ascending ordinal identifying an event's position within an entity's event stream.

A sequence number is an ascending ordinal identifying an event’s position within one entity’s event stream. In a journal, each persisted event receives a sequence number associated with its persistence ID. Numbers advance independently for different entities, so container 9 can have events 1 and 2 while container 11 has event 1. section 9.4 section 10.2

Use sequence numbers to:

  • Track an entity’s position in its persisted event stream. section 9.4
  • Represent the latest event consumed when reading by tag; the corresponding read position is called an offset. section 10.2
  • Read events from a chosen range for a persistence ID through persistence-query APIs. section 10.2

Two containers, separate sequences

Three cargo events produce these journal rows: container 9 receives sequence numbers 1 and 2, while container 11 receives sequence number 1. The database ordering is global, but sequence_number is ordinal within each persistence ID.

How Akka in Action, Second Edition covers it

How deep it goes
Defines per-entity numbering, contrasts it with global ordering, and connects it to query offsets and ranges.
Examples
Uses cargo events for containers 9 and 11, journal tables, tagged reads, and an EventEnvelope containing sequence value 1.
What it assumes
Assumes familiarity with persisted events, persistence IDs, journals, and tagged event queries.
What you can do after
Apply it via Akka Persistence Query to start from no offset or continue from a recorded journal position.
How it connects
Connects sequence numbers to persistence IDs, event journals, event streams, offsets, EventEnvelope values, and persistence queries.

Also explained in

Compare how 3 books explain sequence number →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Akka in Action, Second Edition. The section links point to the parts of the book it draws on.