eventsByTag reads persisted events that share a tag from a Persistence Query read journal. Supply the tag and an offset; Offset.noOffset starts at the beginning of the journal. The query produces a Source of EventEnvelope values, each carrying journal ordering, persistence ID, sequence number, event payload, and timestamp. section 10.2
Read tagged container events
A JDBC read journal can query "container-tag-0" with Offset.noOffset. That tag selects the first two CargoAdded events for persistence ID spcontainer-type-key|9; the returned envelopes expose both the event and its journal position. section 10.2
Tags make a journal useful beyond inspecting stored events:
- Filter for event types or business categories, such as CargoAdded, rather than processing every journal entry. section 10.2
- Partition event processing: separate tag streams can run in parallel, including on different machines. section 10.2
- Build a read-side result by aggregating tagged events, then write it to a separate database or topic. section 10.2.1
- Enrich events after reading them and route transformed results through a pipes-and-filters flow. section 10.2.1
A typical read-side use case calculates total container weight from AddCargo events and upserts the result into another store. Keeping that derived value outside the persistent container avoids predicting every future query and decouples event writing from read-side aggregation. Clustering is optional for the query itself, but supports fault tolerance and scalable processing. section 10.2.1
Akka Projections package this query as an event source provider. A projection selects eventsByTag through its read-journal plugin and tag, then delegates writes to a handler. It manages offsets on restart with effectively-once delivery semantics and can configure parallelism, bounded by the available persistence entity tags. section 10.3 section 10.3.1
Table 10.1 Methods available to consume the journal: inputs and outputs (view table figure)
Compare eventsByTag with currentEventsByTag and the other journal queries by their inputs and outputs. section 10.2
