Class PersistenceTestKitReadJournal
- All Implemented Interfaces:
CurrentEventsByPersistenceIdQuery,CurrentEventsByTagQuery,EventsByPersistenceIdQuery,EventsByTagQuery,ReadJournal,CurrentEventsBySliceQuery,EventsBySliceQuery
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncurrentEventsByPersistenceId(String persistenceId, long fromSequenceNr, long toSequenceNr) Same type of query aspekko.persistence.query.javadsl.EventsByPersistenceIdQuery#eventsByPersistenceIdbut the event stream is completed immediately when it reaches the end of the "result set".<Event> Source<EventEnvelope<Event>,NotUsed> currentEventsBySlices(String entityType, int minSlice, int maxSlice, Offset offset) Same type of query aspekko.persistence.query.typed.javadsl.EventsBySliceQuery.eventsBySlicesbut the event stream is completed immediately when it reaches the end of the "result set".currentEventsByTag(String tag, Offset offset) Same type of query aspekko.persistence.query.javadsl.EventsByTagQuery#eventsByTagbut the event stream is completed immediately when it reaches the end of the "result set".eventsByPersistenceId(String persistenceId, long fromSequenceNr, long toSequenceNr) Query events for a specificPersistentActoridentified bypersistenceId.<Event> Source<EventEnvelope<Event>,NotUsed> eventsBySlices(String entityType, int minSlice, int maxSlice, Offset offset) Query events for given slices.eventsByTag(String tag, Offset offset) Query events that have a specific tag.static StringintsliceForPersistenceId(String persistenceId) sliceRanges(int numberOfRanges)
-
Constructor Details
-
PersistenceTestKitReadJournal
-
-
Method Details
-
Identifier
-
eventsByPersistenceId
public Source<EventEnvelope,NotUsed> eventsByPersistenceId(String persistenceId, long fromSequenceNr, long toSequenceNr) Description copied from interface:EventsByPersistenceIdQueryQuery events for a specificPersistentActoridentified bypersistenceId.You can retrieve a subset of all events by specifying
fromSequenceNrandtoSequenceNror use0LandLong.MAX_VALUErespectively to retrieve all events. The query will return all the events inclusive of thefromSequenceNrandtoSequenceNrvalues.The returned event stream should be ordered by sequence number.
The stream is not completed when it reaches the end of the currently stored events, but it continues to push new events when new events are persisted. Corresponding query that is completed when it reaches the end of the currently stored events is provided by
pekko.persistence.query.javadsl.CurrentEventsByPersistenceIdQuery#currentEventsByPersistenceId.- Specified by:
eventsByPersistenceIdin interfaceEventsByPersistenceIdQuery
-
currentEventsByPersistenceId
public Source<EventEnvelope,NotUsed> currentEventsByPersistenceId(String persistenceId, long fromSequenceNr, long toSequenceNr) Description copied from interface:CurrentEventsByPersistenceIdQuerySame type of query aspekko.persistence.query.javadsl.EventsByPersistenceIdQuery#eventsByPersistenceIdbut the event stream is completed immediately when it reaches the end of the "result set". Events that are stored after the query is completed are not included in the event stream.- Specified by:
currentEventsByPersistenceIdin interfaceCurrentEventsByPersistenceIdQuery
-
currentEventsByTag
Description copied from interface:CurrentEventsByTagQuerySame type of query aspekko.persistence.query.javadsl.EventsByTagQuery#eventsByTagbut the event stream is completed immediately when it reaches the end of the "result set". Depending on journal implementation, this may mean all events up to when the query is started, or it may include events that are persisted while the query is still streaming results. For eventually consistent stores, it may only include all events up to some point before the query is started.- Specified by:
currentEventsByTagin interfaceCurrentEventsByTagQuery
-
currentEventsBySlices
public <Event> Source<EventEnvelope<Event>,NotUsed> currentEventsBySlices(String entityType, int minSlice, int maxSlice, Offset offset) Description copied from interface:CurrentEventsBySliceQuerySame type of query aspekko.persistence.query.typed.javadsl.EventsBySliceQuery.eventsBySlicesbut the event stream is completed immediately when it reaches the end of the "result set". Depending on journal implementation, this may mean all events up to when the query is started, or it may include events that are persisted while the query is still streaming results. For eventually consistent stores, it may only include all events up to some point before the query is started.- Specified by:
currentEventsBySlicesin interfaceCurrentEventsBySliceQuery
-
eventsByTag
Description copied from interface:EventsByTagQueryQuery events that have a specific tag. A tag can for example correspond to an aggregate root type (in DDD terminology).The consumer can keep track of its current position in the event stream by storing the
offsetand restart the query from a givenoffsetafter a crash/restart.The exact meaning of the
offsetdepends on the journal and must be documented by the read journal plugin. It may be a sequential id number that uniquely identifies the position of each event within the event stream. Distributed data stores cannot easily support those semantics and they may use a weaker meaning. For example it may be a timestamp (taken when the event was created or stored). Timestamps are not unique and not strictly ordered, since clocks on different machines may not be synchronized.In strongly consistent stores, where the
offsetis unique and strictly ordered, the stream should start from the next event after theoffset. Otherwise, the read journal should ensure that between an invocation that returned an event with the givenoffsetand this invocation, no events are missed. Depending on the journal implementation, this may mean that this invocation will return events that were already returned by the previous invocation, including the event with the passed inoffset.The returned event stream should be ordered by
offsetif possible, but this can also be difficult to fulfill for a distributed data store. The order must be documented by the read journal plugin.The stream is not completed when it reaches the end of the currently stored events, but it continues to push new events when new events are persisted. Corresponding query that is completed when it reaches the end of the currently stored events is provided by
CurrentEventsByTagQuery.currentEventsByTag(java.lang.String, org.apache.pekko.persistence.query.Offset).- Specified by:
eventsByTagin interfaceEventsByTagQuery
-
eventsBySlices
public <Event> Source<EventEnvelope<Event>,NotUsed> eventsBySlices(String entityType, int minSlice, int maxSlice, Offset offset) Description copied from interface:EventsBySliceQueryQuery events for given slices. A slice is deterministically defined based on the persistence id. The purpose is to evenly distribute all persistence ids over the slices.The consumer can keep track of its current position in the event stream by storing the
offsetand restart the query from a givenoffsetafter a crash/restart.The exact meaning of the
offsetdepends on the journal and must be documented by the read journal plugin. It may be a sequential id number that uniquely identifies the position of each event within the event stream. Distributed data stores cannot easily support those semantics and they may use a weaker meaning. For example it may be a timestamp (taken when the event was created or stored). Timestamps are not unique and not strictly ordered, since clocks on different machines may not be synchronized.In strongly consistent stores, where the
offsetis unique and strictly ordered, the stream should start from the next event after theoffset. Otherwise, the read journal should ensure that between an invocation that returned an event with the givenoffset, and this invocation, no events are missed. Depending on the journal implementation, this may mean that this invocation will return events that were already returned by the previous invocation, including the event with the passed inoffset.The returned event stream should be ordered by
offsetif possible, but this can also be difficult to fulfill for a distributed data store. The order must be documented by the read journal plugin.The stream is not completed when it reaches the end of the currently stored events, but it continues to push new events when new events are persisted. Corresponding query that is completed when it reaches the end of the currently stored events is provided by
CurrentEventsBySliceQuery.currentEventsBySlices.- Specified by:
eventsBySlicesin interfaceEventsBySliceQuery
-
sliceForPersistenceId
- Specified by:
sliceForPersistenceIdin interfaceCurrentEventsBySliceQuery- Specified by:
sliceForPersistenceIdin interfaceEventsBySliceQuery
-
sliceRanges
- Specified by:
sliceRangesin interfaceCurrentEventsBySliceQuery- Specified by:
sliceRangesin interfaceEventsBySliceQuery
-