Allow a segment claim to trigger an ad-hoc replay#4620
Draft
abuijze wants to merge 1 commit into
Draft
Conversation
Extend SegmentChangeListener#onSegmentClaimed to return a TrackingToken on segment claim, the segment's reset position. When the returned token is strictly behind the segment's stored token, the Coordinator wraps the stored token in a ReplayToken so the segment streams from the reset position instead of the stored one. Returning null leaves the stored position untouched. On a first-ever claim (stored token null) the returned token is ignored, as a reset is only meaningful relative to a position the processor has already moved past. Reset positions returned by composed listeners are merged via TrackingToken#lowerBound, yielding the lowest position required by any constituent. Add SegmentChangeListener#onClaimWithReset for listeners that supply such a position. Introduce HandlerAwareProcessorCustomization: a customization hook invoked when a PooledStreamingEventProcessor is built, with access to the resolved EventHandlingComponent list, allowing processor configuration to be derived from the handlers themselves. PooledStreamingEventProcessorModule discovers these customizations from the root configuration so registration location is irrelevant.
|
Contributor
Author
|
Converted back to draft. John had some questions and suggestions that gave me another idea. Working on that one. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Adds two building blocks to the pooled streaming event processor so that a component can request an ad-hoc replay of a single segment at the moment it is claimed.
Segment claim can return a reset position
SegmentChangeListener#onSegmentClaimednow returns aTrackingToken— the position the segment should be reset to. When that token is strictly behind the segment's stored token, theCoordinatorwraps the stored token in aReplayToken, so the segment streams from the returned position instead of the stored one. Returningnullleaves the stored position untouched.null) the returned position is ignored — a reset is only meaningful relative to a position the processor has already moved past. The listener is still invoked for any side effects.andThen) listeners are merged viaTrackingToken#lowerBound, so the chain requests the lowest position any constituent requires.SegmentChangeListener#onClaimWithReset(...)is added for listeners that supply such a position.Handler-aware processor customization
HandlerAwareProcessorCustomizationis a new hook invoked when aPooledStreamingEventProcessoris built, with access to the resolvedEventHandlingComponentlist. This lets processor configuration (such as registering aSegmentChangeListener) be derived from the handlers assigned to that processor.PooledStreamingEventProcessorModulediscovers these customizations from the root configuration, so where they are registered does not matter.Testing
./mvnw -pl messaging test -Dtest='SegmentChangeListenerTest,HandlerAwareProcessorCustomizationTest,CoordinatorTest'— 40 tests, all green.