question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CassandraReadJournal cannot get events by persistence id

See original GitHub issue

Lagom Version (1.2.x / 1.3.x / etc)

1.3.9

API (Scala / Java / Neither / Both)

Scala

Expected Behavior

  1. Persist event A with PersistentEntity whose persistenceId is X
  2. Create a cassandra read journal readJournal:
private val readJournal = 
  PersistenceQuery(actorSystem).readJournalFor[CassandraReadJournal](CassandraReadJournal.Identifier)
  1. get all current events in that read journal by persistenceId X
val events = readJournal
      .currentEventsByPersistenceId(X, 0, Long.MaxValue)
      .runWith(Sink.seq[Any])
  1. yield a sequence containing A

Actual Behavior

events is always empty

Reason

<del> When `currentEventsByPersistenceId` issues a query, the underlying query is:
SELECT tag1, timebucket, timestamp, persistence_id, partition_nr, sequence_nr, writer_uuid, ser_id, ser_manifest, event_manifest, event, message
         FROM whatever_keyspace.messages
         WHERE persistence_id IS NOT NULL AND partition_nr IS NOT NULL AND sequence_nr IS NOT NULL
           AND tag1 IS NOT NULL AND timestamp IS NOT NULL AND timebucket IS NOT NULL
         PRIMARY KEY ((tag1, timebucket), time... [truncated output]

However, Lagom’s persistence does not persist tag1, tag2, tag3, or message. Therefore, the resultant select yields an empty list.

</del> `persistenceId` is not the same thing as the persistent entity's Id.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
eripcommented, Oct 24, 2017

@ignasi35 For complete closure, I’ll post a notional solution:

Because entityTypeName is a class member (not static), I added entityTypeName to a companion object to my PersistentEntity, with which I override the PersistentEntity’s entityTypeName. Then I can access a static persistenceId and futureproof my DB (like the docs mention).

0reactions
eripcommented, Oct 24, 2017

And to confirm, the above solution worked. 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to get events by tags - Persistence / Event Sourcing
I am unable to get events by tags, I am using akka 2.5.23, akka-persistence-cassandra 0.98, and Cassandra 3.6 This is part of my...
Read more >
Query Plugin • Akka Persistence Cassandra - Documentation
A Cassandra plugin for Akka Persistence. ... Persistence Query usage example to obtain a stream with all events tagged with ... Identifier) queries....
Read more >
Events are not recovering in Akka 2.4.0 Persistence ...
So, take the default cassandra-journal config and override the keyspace . Then, like you're doing, overriding persistenceId in the Akka ...
Read more >
Akka persistence - Beyond the lines
It's possible to query the metadata (persistence id, timestamps, ... However we get only the events of a single actor (because of the...
Read more >
akka.persistence.query.PersistenceQuery Scala Example
toString } // provides a unique persistence-id per test case and some initial persisted events protected trait Setup { lazy val probe =...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found