-
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.
Fire CatchupStartedEvent at the correct time to allow for multiple co…
…mponent catchups
- Loading branch information
amckenzie
committed
Jan 21, 2020
1 parent
b51f738
commit a744f70
Showing
20 changed files
with
451 additions
and
337 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
6 changes: 4 additions & 2 deletions
6
...ocess/RunCatchupForComponentSelector.java → ...ent/catchup/process/CanCatchupFilter.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
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
35 changes: 26 additions & 9 deletions
35
...ava/uk/gov/justice/services/eventstore/management/catchup/process/EventCatchupRunner.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 |
---|---|---|
@@ -1,27 +1,44 @@ | ||
package uk.gov.justice.services.eventstore.management.catchup.process; | ||
|
||
import uk.gov.justice.services.common.util.UtcClock; | ||
import uk.gov.justice.services.eventstore.management.commands.CatchupCommand; | ||
import uk.gov.justice.subscription.registry.SubscriptionsDescriptorsRegistry; | ||
import uk.gov.justice.services.eventstore.management.events.catchup.CatchupStartedEvent; | ||
import uk.gov.justice.services.eventstore.management.events.catchup.SubscriptionCatchupDetails; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
import javax.enterprise.event.Event; | ||
import javax.inject.Inject; | ||
|
||
public class EventCatchupRunner { | ||
|
||
@Inject | ||
private SubscriptionsDescriptorsRegistry subscriptionsDescriptorsRegistry; | ||
private EventCatchupByComponentRunner eventCatchupByComponentRunner; | ||
|
||
@Inject | ||
private EventCatchupByComponentRunner eventCatchupByComponentRunner; | ||
private Event<CatchupStartedEvent> catchupStartedEventFirer; | ||
|
||
@Inject | ||
private SubscriptionCatchupProvider subscriptionCatchupProvider; | ||
|
||
@Inject | ||
private UtcClock clock; | ||
|
||
public void runEventCatchup(final UUID commandId, final CatchupCommand catchupCommand) { | ||
|
||
subscriptionsDescriptorsRegistry | ||
.getAll() | ||
.forEach(subscriptionsDescriptor -> eventCatchupByComponentRunner.runEventCatchupForComponent( | ||
commandId, | ||
subscriptionsDescriptor, | ||
catchupCommand)); | ||
final List<SubscriptionCatchupDetails> subscriptionCatchupDefinitions = subscriptionCatchupProvider.getBySubscription(catchupCommand); | ||
|
||
catchupStartedEventFirer.fire(new CatchupStartedEvent( | ||
commandId, | ||
catchupCommand, | ||
subscriptionCatchupDefinitions, | ||
clock.now() | ||
)); | ||
|
||
subscriptionCatchupDefinitions.forEach(catchupFor -> eventCatchupByComponentRunner.runEventCatchupForComponent( | ||
catchupFor, | ||
commandId, | ||
catchupCommand)); | ||
} | ||
} |
Oops, something went wrong.