liveBook · Manning

ReadJournal

As explained in Akka in Action, Second Edition

ReadJournal is an Akka Persistence Query interface that provides methods for reading events from a journal.

ReadJournal is the Akka Persistence Query interface for reading event-sourced entity events and projecting them into stores optimized for queries. Results arrive as Akka Streams streams, which remain open because new events may appear at any time. section 10.2

Choose a query according to the event identity and starting point:

  • Use eventsByTag or currentEventsByTag with a tag and offset; Offset.noOffset starts reading from the beginning. section 10.2
  • Select standard queries for historical events and current queries for events arriving after query execution. section 10.2

Printing stored persistence IDs

val readJournal = PersistenceQuery(system).readJournalFor[JdbcReadJournal](JdbcReadJournal.Identifier) val source = readJournal.persistenceIds source.runForeach(println) The read journal is obtained from the configured JDBC implementation, then its source is materialized to print each identifier.

ReadJournal requires a plugin implementation, such as Cassandra, Couchbase, or JDBC. A JDBC setup can use PostgreSQL for journal events and snapshots. Akka projections commonly consume eventsByTag, manage offsets, and write transformed data to another store. section 10.2 section 10.3

How Akka in Action, Second Edition covers it

How deep it goes
Defines query families, offsets, stream behavior, and plugins, but defers detailed database implementation.
Examples
Uses Scala examples that print persistence IDs, query tagged events, inspect EventEnvelope values, and configure JDBC with PostgreSQL.
What it assumes
Requires a configured persistence-query plugin and an Akka system capable of consuming Akka Streams sources.
What you can do after
Apply via Akka Persistence Query to obtain journal streams, select query ranges, consume events, and feed projections.
How it connects
Connects event sourcing, Akka Streams, persistence IDs, offsets, journal plugins, EventEnvelope, and projections.

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.