CommandLogEntryRepository
Provides supporting functionality for querying CommandLogEntry entities.
API
interface CommandLogEntryRepository {
CommandLogEntry createEntryAndPersist(Command command, UUID parentInteractionIdIfAny, ExecuteIn executeIn)
Optional<CommandLogEntry> findByInteractionId(UUID interactionId)
List<CommandLogEntry> findByParent(CommandLogEntry parent)
List<CommandLogEntry> findByParentInteractionId(UUID parentInteractionId)
List<CommandLogEntry> findByFromAndTo(LocalDate from, LocalDate to)
List<CommandLogEntry> findCurrent()
List<CommandLogEntry> findCompleted()
List<CommandLogEntry> findByTargetAndFromAndTo(Bookmark target, LocalDate from, LocalDate to)
List<CommandLogEntry> findMostRecent()
List<CommandLogEntry> findMostRecent(int limit)
List<CommandLogEntry> findRecentByUsername(String username)
List<CommandLogEntry> findRecentByTarget(Bookmark target)
List<CommandLogEntry> findRecentByTargetOrResult(Bookmark targetOrResult)
List<CommandLogEntry> findSince(UUID interactionId, Integer batchSize) (1)
List<CommandLogEntry> findBackgroundAndNotYetStarted() (2)
List<CommandLogEntry> findRecentBackgroundByTarget(Bookmark target)
Optional<CommandLogEntry> findMostRecentReplayed() (3)
Optional<CommandLogEntry> findMostRecentCompleted() (4)
List<CommandLogEntry> findNotYetReplayed()
CommandLogEntry saveForReplay(CommandDto dto)
List<CommandLogEntry> saveForReplay(CommandsDto commandsDto)
void persist(CommandLogEntry commandLogEntry)
void truncateLog()
List<CommandLogEntry> findCommandsOnPrimaryElseFail(UUID interactionId, Integer batchSize)
List<CommandLogEntry> findAll() (5)
void removeAll() (6)
}
1 | findSince(UUID, Integer)
Intended to support the replay of commands on a secondary instance of the application. This finder returns all (completed) CommandLogEntry s started after the command with the specified interactionId. The number of commands returned can be limited so that they can be applied in batches. If the provided interactionId is null, then only a single CommandLogEntry is returned. This is intended to support the case when the secondary does not yet have any CommandLogEntry s replicated. In practice this is unlikely; typically we expect that the secondary will be set up to run against a copy of the primary instance’s DB (restored from a backup), in which case there will already be a CommandLogEntry representing the current high water mark on the secondary system. If the interactionId is not null but the corresponding CommandLogEntry is not found, then |
2 | findBackgroundAndNotYetStarted()
Returns any persisted commands that have not yet started. |
3 | findMostRecentReplayed()
The most recent replayed command previously replicated from primary to secondary. |
4 | findMostRecentCompleted()
The most recent completed command, as queried on the secondary. |
5 | findAll()
intended for testing purposes only |
6 | removeAll()
intended for testing purposes only |
Members
findSince(UUID, Integer)
Intended to support the replay of commands on a secondary instance of the application. This finder returns all (completed) CommandLogEntry s started after the command with the specified interactionId. The number of commands returned can be limited so that they can be applied in batches. If the provided interactionId is null, then only a single CommandLogEntry is returned. This is intended to support the case when the secondary does not yet have any CommandLogEntry s replicated. In practice this is unlikely; typically we expect that the secondary will be set up to run against a copy of the primary instance’s DB (restored from a backup), in which case there will already be a CommandLogEntry representing the current high water mark on the secondary system. If the interactionId is not null but the corresponding CommandLogEntry is not found, then null
is returned. In the replay scenario the caller will probably interpret this as an error because it means that the high water mark on the secondary is inaccurate, referring to a non-existent CommandLogEntry on the primary.
findBackgroundAndNotYetStarted()
Returns any persisted commands that have not yet started.
This is to support the notion of background commands (the same as their implementation in v1) whereby a custom executor service for org.apache.causeway.applib.services.wrapper.WrapperFactory would "execute" a Command simply by persisting it as a CommandLogEntry , so that a quartz or similar background job could execute the Command at some point later.
findMostRecentReplayed()
The most recent replayed command previously replicated from primary to secondary.
This should always exist except for the very first times (after restored the prod DB to secondary).