-
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 new CatchupProcessingOfEventFailedEvent if processing of Publish…
…edEvent during catchup fails
- Loading branch information
amckenzie
committed
Sep 28, 2019
1 parent
816620a
commit 9abbf92
Showing
29 changed files
with
829 additions
and
218 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
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
39 changes: 39 additions & 0 deletions
39
...vices/event/sourcing/subscription/catchup/consumer/task/EventProcessingFailedHandler.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.services.event.sourcing.subscription.catchup.consumer.task; | ||
|
||
import static java.lang.String.format; | ||
|
||
import uk.gov.justice.services.eventsourcing.repository.jdbc.event.PublishedEvent; | ||
import uk.gov.justice.services.eventstore.management.events.catchup.CatchupProcessingOfEventFailedEvent; | ||
import uk.gov.justice.services.eventstore.management.events.catchup.CatchupType; | ||
|
||
import javax.enterprise.event.Event; | ||
import javax.inject.Inject; | ||
|
||
import org.slf4j.Logger; | ||
|
||
public class EventProcessingFailedHandler { | ||
|
||
@Inject | ||
private Event<CatchupProcessingOfEventFailedEvent> catchupProcessingOfEventFailedEventFirer; | ||
|
||
@Inject | ||
private Logger logger; | ||
|
||
public void handle(final RuntimeException exception, final PublishedEvent publishedEvent, final String subscriptionName, final CatchupType catchupType) { | ||
|
||
final String logMessage = format("Failed to process publishedEvent with metadata: %s", publishedEvent.getMetadata()); | ||
logger.error( | ||
logMessage, | ||
exception); | ||
|
||
final CatchupProcessingOfEventFailedEvent catchupProcessingOfEventFailedEvent = new CatchupProcessingOfEventFailedEvent( | ||
publishedEvent.getId(), | ||
publishedEvent.getMetadata(), | ||
exception, | ||
catchupType, | ||
subscriptionName | ||
); | ||
|
||
catchupProcessingOfEventFailedEventFirer.fire(catchupProcessingOfEventFailedEvent); | ||
} | ||
} |
21 changes: 9 additions & 12 deletions
21
...ustice/services/event/sourcing/subscription/catchup/consumer/task/EventQueueConsumer.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
41 changes: 41 additions & 0 deletions
41
...s/event/sourcing/subscription/catchup/consumer/manager/EventQueueConsumerFactoryTest.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,41 @@ | ||
package uk.gov.justice.services.event.sourcing.subscription.catchup.consumer.manager; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.junit.Assert.assertThat; | ||
import static org.mockito.Mockito.mock; | ||
import static uk.gov.justice.services.test.utils.core.reflection.ReflectionUtil.getValueOfField; | ||
|
||
import uk.gov.justice.services.event.sourcing.subscription.catchup.consumer.task.EventProcessingFailedHandler; | ||
import uk.gov.justice.services.event.sourcing.subscription.catchup.consumer.task.EventQueueConsumer; | ||
import uk.gov.justice.services.event.sourcing.subscription.manager.TransactionalEventProcessor; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.runners.MockitoJUnitRunner; | ||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class EventQueueConsumerFactoryTest { | ||
|
||
@Mock | ||
private TransactionalEventProcessor transactionalEventProcessor; | ||
|
||
@Mock | ||
private EventProcessingFailedHandler eventProcessingFailedHandler; | ||
|
||
@InjectMocks | ||
private EventQueueConsumerFactory eventQueueConsumerFactory; | ||
|
||
@Test | ||
public void shouldCreateEventQueueConsumerFactory() throws Exception { | ||
|
||
final EventStreamConsumptionResolver eventStreamConsumptionResolver = mock(EventStreamConsumptionResolver.class); | ||
|
||
final EventQueueConsumer eventQueueConsumer = eventQueueConsumerFactory.create(eventStreamConsumptionResolver); | ||
|
||
assertThat(getValueOfField(eventQueueConsumer, "transactionalEventProcessor", TransactionalEventProcessor.class), is(transactionalEventProcessor)); | ||
assertThat(getValueOfField(eventQueueConsumer, "eventStreamConsumptionResolver", EventStreamConsumptionResolver.class), is(eventStreamConsumptionResolver)); | ||
assertThat(getValueOfField(eventQueueConsumer, "eventProcessingFailedHandler", EventProcessingFailedHandler.class), is(eventProcessingFailedHandler)); | ||
} | ||
} |
Oops, something went wrong.