-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Load events in batches of 1000 when processing stream
- Loading branch information
Showing
13 changed files
with
312 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...eplay/src/main/java/uk/gov/justice/framework/tools/replay/JsonEnvelopeJdbcRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package uk.gov.justice.framework.tools.replay; | ||
|
||
import static java.lang.String.format; | ||
|
||
import uk.gov.justice.services.eventsourcing.repository.jdbc.event.EventConverter; | ||
import uk.gov.justice.services.eventsourcing.repository.jdbc.event.EventJdbcRepository; | ||
import uk.gov.justice.services.messaging.JsonEnvelope; | ||
|
||
import java.util.UUID; | ||
import java.util.stream.Stream; | ||
|
||
import javax.inject.Inject; | ||
|
||
public class JsonEnvelopeJdbcRepository { | ||
|
||
private static final long PAGE_SIZE_OF_ONE = 1L; | ||
@Inject | ||
private EventJdbcRepository eventJdbcRepository; | ||
|
||
@Inject | ||
private EventConverter eventConverter; | ||
|
||
public Stream<JsonEnvelope> forward(final UUID streamId, final long position, final long pageSize) { | ||
return eventJdbcRepository | ||
.forward(streamId, position, pageSize) | ||
.map(eventConverter::envelopeOf); | ||
} | ||
|
||
public JsonEnvelope head(final UUID streamId) { | ||
return eventJdbcRepository.head(streamId, PAGE_SIZE_OF_ONE) | ||
.findFirst() | ||
.map(eventConverter::envelopeOf) | ||
.orElseThrow(() -> new RuntimeException(format("Failed to get head for stream id: %s", streamId))); | ||
} | ||
|
||
public long getLatestSequenceIdForStream(final UUID streamId) { | ||
return eventJdbcRepository.getLatestSequenceIdForStream(streamId); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...rk-tools-replay/src/main/java/uk/gov/justice/framework/tools/replay/JsonEnvelopeUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package uk.gov.justice.framework.tools.replay; | ||
|
||
import uk.gov.justice.services.messaging.JsonEnvelope; | ||
|
||
public class JsonEnvelopeUtil { | ||
|
||
public Long versionOf(final JsonEnvelope jsonEnvelope) { | ||
return jsonEnvelope | ||
.metadata() | ||
.version() | ||
.orElse(-1L); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.