Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eventsByPersistenceId query from an actor makes actor's context = null #38

Open
ShahOdin opened this issue Jul 11, 2017 · 1 comment
Open
Labels

Comments

@ShahOdin
Copy link

ShahOdin commented Jul 11, 2017

Finally pinpointed the problem. I define a trait:

trait InMemQuerySupport extends Actor {
        import akka.NotUsed
        import akka.persistence.query.{EventEnvelope, PersistenceQuery}
        import akka.stream.scaladsl.Source
        import akka.persistence.inmemory.query.scaladsl.InMemoryReadJournal

        def queryJournal(idToQuery: String, fromSequenceNr: Long = 0L,
                         toSequenceNr: Long = Long.MaxValue): Source[EventEnvelope, NotUsed] = {
          val source = PersistenceQuery(context.system).           
          readJournalFor[InMemoryReadJournal](InMemoryReadJournal.Identifier).
          eventsByPersistenceId(idToQuery, fromSequenceNr, toSequenceNr)
        }

        def queryJournalFrom(idToQuery: String, fromSequenceNr: Long = 0L): Source[EventEnvelope, NotUsed] =
          {
          assert(context != null, "This passes.")
          val source = queryJournal(idToQuery, fromSequenceNr, Long.MaxValue)
          assert(context != null, "This fails.")
          source
           }

      }

which I mix-in with a persistent actor. Calling queryJournalFrom(queryId, offsetForNextFetch) inside the actor in a test during the recovery phase for the actor causes the assertion above to fail. This is the full context of the code above. and although the system works in the demo, integrating it into another project with the same environment fails. This doesn't seem to happen with Cassandra's journal plugin.

@ShahOdin ShahOdin reopened this Jul 12, 2017
@ShahOdin ShahOdin changed the title InMemoryReadJournal not returning sharded Persistent actor's events eventsByPersistenceId not returning existing events? Jul 12, 2017
@ShahOdin ShahOdin reopened this Jul 13, 2017
@ShahOdin ShahOdin changed the title eventsByPersistenceId not returning existing events? eventsByPersistenceId query from an actor makes actor's context = null Jul 13, 2017
@dnvriend
Copy link
Owner

Will put this on the backlog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants