Skip to content

A small study project on the akka-persistence-query API as there is no TCK

License

Notifications You must be signed in to change notification settings

epiphyllum/akka-persistence-query-test

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

akka-persistence-query-test

Study on the akka-persistence-query API. As there is no Technology Compatibility Kit (TCK) as of yet for akka-persistence-query, I will be looking at the leveldb implementation that comes out of the box with akka and assert the behavior so that I can replicate it in the akka-persistence-inmemory and akka-persistence-jdbc plugins.

Conclusions

The following are my findings.

CurrentPersistenceIds API

  • Empty journal: Apparently the leveldb query API is magical, with an empty journal (no events), it still can determine the persistenceIds of any running persistent actor, this is something that cannot be reproduced with the inmemory plugin or the jdbc plugin,
  • The emitted element type is String,
  • PersistenceIds, are streamed in a non-deterministic order,
  • PersistenceIds are emitted only once, so the API is stateful.

EventsByPersistenceIds

final case class EventEnvelope(
  offset:        Long,
  persistenceId: String,
  sequenceNr:    Long,
  event:         Any)
  • The EventEnvelope has a field called offset which is kind of confusing. With the eventsByPersistenceIds, the offset value is the same as the event sequenceNr. This behavior is different from the byTag queries.
  • Using the from/to sequenceNr fields in the query, the following table applies when there are three events:
from to result
0 1 EventEnvelope(1, persistenceId, 1, event)
1 1 EventEnvelope(1, persistenceId, 1, event)
1 2 EventEnvelope(1, persistenceId, 1, event), EventEnvelope(2, persistenceId, 2, event)
2 2 EventEnvelope(2, persistenceId, 2, event)
2 3 EventEnvelope(2, persistenceId, 2, event), EventEnvelope(3, persistenceId, 3, event)
3 3 EventEnvelope(3, persistenceId, 3, event)
0 3 EventEnvelope(1, persistenceId, 1, event), EventEnvelope(2, persistenceId, 2, event), EventEnvelope(3, persistenceId, 3, event)
1 3 EventEnvelope(1, persistenceId, 1, event), EventEnvelope(2, persistenceId, 2, event), EventEnvelope(3, persistenceId, 3, event)

EventsByPersistenceId should terminate when the toSequenceNr has been reached. Also, but not implemented by the levelDb journal, it should also terminate when the toSeqnr is equal to zero (0)

EventsByTag API

  • The emitted element is akka.persistence.query.EventEnvelope,
  • The field offset is a generated number that is added to the event stream that tags that emitted event with a unique number for that query,
  • Using the offset field in the query, the following table applies when three events match the query:
offset result
0 EventEnvelope(1, _, _, _), EventEnvelope(2, _, _, _), EventEnvelope(3, _, _, _)
1 EventEnvelope(1, _, _, _), EventEnvelope(2, _, _, _), EventEnvelope(3, _, _, _)
2 EventEnvelope(2, _, _, _), EventEnvelope(3, _, _, _)
3 EventEnvelope(3, _, _, _)
4 No events are emitted

What's new?

1.0.0 (2016-06-09)

  • Initial

Have fun!

About

A small study project on the akka-persistence-query API as there is no TCK

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Scala 100.0%