Yanire Romero
Yanire Romero

Reputation: 482

How to read the journal at a specific point in time with akka event sourcing

I am currently trying to implement a git like storage with akka event sourcing in combination with CQRS. The write path is implemented via an EventSourcedBehavior actor (will refer to it as GitCommitter) that validates the integrity of the data and keeps all commits as part of its state in an ordered list which last element could be thought of as the HEAD.

The GitCommitter sends the HEAD commit to a projection actor (refer to as GitReader) as part of its protocol. When a read request is received a message is sent to GitReader and it returns a view based on its state.

The main problem with this approach is that it is not possible to read the history of commits at a given revision only at HEAD. I was exploring switching to akka projection instead and eventsByTag for example by tagging commit events with a revision but then how can the projection be used to read the entity at a given revision? As in replaying events only until a given tag for a given entity?

Would I have to use the revision as an offset?

In a sharded cluster is the projection spawned by tag and not associated to the persistence id used in the GitCommitter actor? It was not stated explicitly here but I understood that tags should be treated as constant values, in my case revisions are generated with every new event. The database I am using is DynamoDB.

I am not sure if I am in the right path, it feels like reading from a journal at a given point in time is not an uncommon feature but I can't find any guidance in the documentation. Any help is appreciated!

Upvotes: -1

Views: 56

Answers (1)

Levi Ramsey
Levi Ramsey

Reputation: 20561

It's not entirely clear from the question, but if the GitReader will be concerned with replaying the events of one particular persistence ID, the eventsByPersistenceId or currentEventsByPersistenceId query is probably the one to use. You shouldn't need to use Projection (that's intended for long-running processes that are persisting a durable read-model (to use the CQRS term)).

Upvotes: 0

Related Questions