Skip to content

Commit

Permalink
Change command handlers to be called using Strings
Browse files Browse the repository at this point in the history
  • Loading branch information
amckenzie committed Nov 7, 2019
1 parent b634c8f commit 45b9c9a
Show file tree
Hide file tree
Showing 90 changed files with 660 additions and 107 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ on [Keep a CHANGELOG](http://keepachangelog.com/). This project adheres to
[Semantic Versioning](http://semver.org/).

## [Unreleased]

## [2.3.0] - 2019-12-07
### Added
- Added event_id to the processed_event table to aid debugging of publishing
### Changed
- Event-Store SystemCommands moved into this project to break the dependency on framework

## [2.2.7] - 2019-12-04
### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
@Default
public class DummySystemCommandStore implements SystemCommandStore {

@Override
public boolean isSupported(final SystemCommand systemCommand) {
return false;
}

@Override
public SystemCommandHandlerProxy findCommandProxy(final SystemCommand systemCommand) {
throw new UnsupportedOperationException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import uk.gov.justice.services.eventsourcing.publishedevent.rebuild.ActiveEventStreamIdProvider;
import uk.gov.justice.services.eventsourcing.publishedevent.rebuild.PublishedEventConverter;
import uk.gov.justice.services.eventsourcing.publishedevent.rebuild.PublishedEventRebuilder;
import uk.gov.justice.services.eventsourcing.publishedevent.rebuild.integration.helpers.DummySystemCommandStore;
import uk.gov.justice.services.eventsourcing.publishedevent.rebuild.integration.helpers.EventInserter;
import uk.gov.justice.services.eventsourcing.publishedevent.rebuild.integration.helpers.StreamIdGenerator;
import uk.gov.justice.services.eventsourcing.publishedevent.rebuild.integration.helpers.StreamStatusInserter;
Expand Down Expand Up @@ -101,7 +102,8 @@ public Properties postgresqlConfiguration() {
ObjectMapperProducer.class,
LoggerProducer.class,
DefaultJsonEnvelopeProvider.class,
DefaultEnvelopeProvider.class
DefaultEnvelopeProvider.class,
DummySystemCommandStore.class
})
@Default
public WebApp war() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package uk.gov.justice.services.eventsourcing.publishedevent.rebuild.integration.helpers;

import uk.gov.justice.services.jmx.api.command.SystemCommand;
import uk.gov.justice.services.jmx.command.SystemCommandHandlerProxy;
import uk.gov.justice.services.jmx.command.SystemCommandStore;

import java.util.List;

import javax.enterprise.inject.Default;
import javax.faces.bean.ApplicationScoped;

@ApplicationScoped
@Default
public class DummySystemCommandStore implements SystemCommandStore {

@Override
public SystemCommandHandlerProxy findCommandProxy(final SystemCommand systemCommand) {
throw new UnsupportedOperationException();
}

@Override
public void store(final List<SystemCommandHandlerProxy> systemCommandProxies) {
}
}
5 changes: 5 additions & 0 deletions event-sourcing/subscription-manager/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@
<artifactId>event-store-management-events</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>uk.gov.justice.event-store</groupId>
<artifactId>event-store-management-commands</artifactId>
<version>${project.version}</version>
</dependency>

<!--Test Dependencies-->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import uk.gov.justice.services.event.sourcing.subscription.catchup.consumer.task.ConsumeEventQueueTaskManager;
import uk.gov.justice.services.event.sourcing.subscription.catchup.consumer.task.EventQueueConsumer;
import uk.gov.justice.services.eventsourcing.repository.jdbc.event.PublishedEvent;
import uk.gov.justice.services.jmx.api.command.CatchupCommand;
import uk.gov.justice.services.eventstore.management.commands.CatchupCommand;

import java.util.Queue;
import java.util.UUID;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package uk.gov.justice.services.event.sourcing.subscription.catchup.consumer.manager;

import uk.gov.justice.services.eventsourcing.repository.jdbc.event.PublishedEvent;
import uk.gov.justice.services.jmx.api.command.CatchupCommand;
import uk.gov.justice.services.eventstore.management.commands.CatchupCommand;

import java.util.UUID;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import static javax.transaction.Transactional.TxType.NEVER;

import uk.gov.justice.services.eventsourcing.repository.jdbc.event.PublishedEvent;
import uk.gov.justice.services.jmx.api.command.CatchupCommand;
import uk.gov.justice.services.eventstore.management.commands.CatchupCommand;

import java.util.Queue;
import java.util.UUID;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package uk.gov.justice.services.event.sourcing.subscription.catchup.consumer.task;

import uk.gov.justice.services.eventsourcing.repository.jdbc.event.PublishedEvent;
import uk.gov.justice.services.jmx.api.command.CatchupCommand;
import uk.gov.justice.services.eventstore.management.commands.CatchupCommand;

import java.util.Queue;
import java.util.UUID;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package uk.gov.justice.services.event.sourcing.subscription.catchup.consumer.task;

import uk.gov.justice.services.eventsourcing.repository.jdbc.event.PublishedEvent;
import uk.gov.justice.services.jmx.api.command.CatchupCommand;
import uk.gov.justice.services.eventstore.management.commands.CatchupCommand;

import java.util.Queue;
import java.util.UUID;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package uk.gov.justice.services.event.sourcing.subscription.catchup.consumer.task;

import uk.gov.justice.services.eventsourcing.repository.jdbc.event.PublishedEvent;
import uk.gov.justice.services.jmx.api.command.CatchupCommand;
import uk.gov.justice.services.eventstore.management.commands.CatchupCommand;

import java.util.Queue;
import java.util.UUID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import static java.lang.String.format;

import uk.gov.justice.services.eventsourcing.repository.jdbc.event.PublishedEvent;
import uk.gov.justice.services.eventstore.management.commands.CatchupCommand;
import uk.gov.justice.services.eventstore.management.events.catchup.CatchupProcessingOfEventFailedEvent;
import uk.gov.justice.services.jmx.api.command.CatchupCommand;

import java.util.UUID;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import uk.gov.justice.services.event.sourcing.subscription.catchup.consumer.manager.FinishedProcessingMessage;
import uk.gov.justice.services.event.sourcing.subscription.manager.TransactionalEventProcessor;
import uk.gov.justice.services.eventsourcing.repository.jdbc.event.PublishedEvent;
import uk.gov.justice.services.jmx.api.command.CatchupCommand;
import uk.gov.justice.services.eventstore.management.commands.CatchupCommand;

import java.util.Queue;
import java.util.UUID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
@Default
public class DummySystemCommandStore implements SystemCommandStore {

@Override
public boolean isSupported(final SystemCommand systemCommand) {
return false;
}

@Override
public SystemCommandHandlerProxy findCommandProxy(final SystemCommand systemCommand) {
throw new UnsupportedOperationException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import uk.gov.justice.services.event.sourcing.subscription.catchup.consumer.task.ConsumeEventQueueTaskManager;
import uk.gov.justice.services.event.sourcing.subscription.catchup.consumer.task.EventQueueConsumer;
import uk.gov.justice.services.eventsourcing.repository.jdbc.event.PublishedEvent;
import uk.gov.justice.services.jmx.api.command.CatchupCommand;
import uk.gov.justice.services.jmx.api.command.EventCatchupCommand;
import uk.gov.justice.services.eventstore.management.commands.CatchupCommand;
import uk.gov.justice.services.eventstore.management.commands.EventCatchupCommand;

import java.util.List;
import java.util.Queue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import static org.mockito.Mockito.when;

import uk.gov.justice.services.eventsourcing.repository.jdbc.event.PublishedEvent;
import uk.gov.justice.services.jmx.api.command.CatchupCommand;
import uk.gov.justice.services.jmx.api.command.EventCatchupCommand;
import uk.gov.justice.services.eventstore.management.commands.CatchupCommand;
import uk.gov.justice.services.eventstore.management.commands.EventCatchupCommand;

import java.util.Queue;
import java.util.UUID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import static uk.gov.justice.services.test.utils.core.reflection.ReflectionUtil.getValueOfField;

import uk.gov.justice.services.eventsourcing.repository.jdbc.event.PublishedEvent;
import uk.gov.justice.services.jmx.api.command.CatchupCommand;
import uk.gov.justice.services.jmx.api.command.EventCatchupCommand;
import uk.gov.justice.services.eventstore.management.commands.CatchupCommand;
import uk.gov.justice.services.eventstore.management.commands.EventCatchupCommand;

import java.util.Queue;
import java.util.UUID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import static org.mockito.Mockito.when;

import uk.gov.justice.services.eventsourcing.repository.jdbc.event.PublishedEvent;
import uk.gov.justice.services.jmx.api.command.CatchupCommand;
import uk.gov.justice.services.jmx.api.command.EventCatchupCommand;
import uk.gov.justice.services.eventstore.management.commands.CatchupCommand;
import uk.gov.justice.services.eventstore.management.commands.EventCatchupCommand;

import java.util.Queue;
import java.util.UUID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import static org.mockito.Mockito.verify;

import uk.gov.justice.services.eventsourcing.repository.jdbc.event.PublishedEvent;
import uk.gov.justice.services.jmx.api.command.CatchupCommand;
import uk.gov.justice.services.jmx.api.command.EventCatchupCommand;
import uk.gov.justice.services.eventstore.management.commands.CatchupCommand;
import uk.gov.justice.services.eventstore.management.commands.EventCatchupCommand;

import java.util.Queue;
import java.util.UUID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import static org.mockito.Mockito.when;

import uk.gov.justice.services.eventsourcing.repository.jdbc.event.PublishedEvent;
import uk.gov.justice.services.eventstore.management.commands.CatchupCommand;
import uk.gov.justice.services.eventstore.management.commands.EventCatchupCommand;
import uk.gov.justice.services.eventstore.management.events.catchup.CatchupProcessingOfEventFailedEvent;
import uk.gov.justice.services.jmx.api.command.CatchupCommand;
import uk.gov.justice.services.jmx.api.command.EventCatchupCommand;

import java.util.UUID;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import uk.gov.justice.services.event.sourcing.subscription.catchup.consumer.manager.FinishedProcessingMessage;
import uk.gov.justice.services.event.sourcing.subscription.manager.TransactionalEventProcessor;
import uk.gov.justice.services.eventsourcing.repository.jdbc.event.PublishedEvent;
import uk.gov.justice.services.jmx.api.command.CatchupCommand;
import uk.gov.justice.services.jmx.api.command.EventCatchupCommand;
import uk.gov.justice.services.eventstore.management.commands.CatchupCommand;
import uk.gov.justice.services.eventstore.management.commands.EventCatchupCommand;

import java.util.Queue;
import java.util.UUID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import uk.gov.justice.services.event.sourcing.subscription.catchup.consumer.manager.ConcurrentEventStreamConsumerManager;
import uk.gov.justice.services.eventsourcing.repository.jdbc.event.PublishedEvent;
import uk.gov.justice.services.jmx.api.command.EventCatchupCommand;
import uk.gov.justice.services.eventstore.management.commands.EventCatchupCommand;

import java.util.UUID;
import java.util.stream.Stream;
Expand Down
22 changes: 22 additions & 0 deletions event-store-management/event-store-management-commands/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>event-store-management</artifactId>
<groupId>uk.gov.justice.event-store</groupId>
<version>2.2.8-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>event-store-management-commands</artifactId>

<dependencies>
<dependency>
<groupId>uk.gov.justice.services</groupId>
<artifactId>jmx-api</artifactId>
<version>${framework.version}</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package uk.gov.justice.services.eventstore.management.commands;

import uk.gov.justice.services.jmx.api.command.BaseSystemCommand;

public class AddTriggerCommand extends BaseSystemCommand {

public static final String ADD_TRIGGER = "ADD_TRIGGER";
private static final String DESCRIPTION = "Adds the 'queue_publish_event' trigger to the event log table so that new events inserted into the event_log table will trigger publishing.";

public AddTriggerCommand() {
super(ADD_TRIGGER, DESCRIPTION);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package uk.gov.justice.services.eventstore.management.commands;

import static uk.gov.justice.services.eventstore.management.commands.EventCatchupCommand.CATCHUP;

import uk.gov.justice.services.jmx.api.command.SystemCommand;


public interface CatchupCommand extends SystemCommand {

default boolean isEventCatchup() {
return CATCHUP.equals(getName());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package uk.gov.justice.services.eventstore.management.commands;

import uk.gov.justice.services.jmx.api.command.BaseSystemCommand;

public class DisablePublishingCommand extends BaseSystemCommand implements PublishingCommand {

public static final String DISABLE_PUBLISHING = "DISABLE_PUBLISHING";
public static final String DESCRIPTION = "Disables the publishing of any newly received events";

public DisablePublishingCommand() {
super(DISABLE_PUBLISHING, DESCRIPTION);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package uk.gov.justice.services.eventstore.management.commands;

import uk.gov.justice.services.jmx.api.command.BaseSystemCommand;

public class EnablePublishingCommand extends BaseSystemCommand implements PublishingCommand {

public static final String ENABLE_PUBLISHING = "ENABLE_PUBLISHING";
public static final String DESCRIPTION = "Enables the publishing of any newly received events";

public EnablePublishingCommand() {
super(ENABLE_PUBLISHING, DESCRIPTION);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package uk.gov.justice.services.eventstore.management.commands;

import uk.gov.justice.services.jmx.api.command.BaseSystemCommand;

public class EventCatchupCommand extends BaseSystemCommand implements CatchupCommand {

public static final String CATCHUP = "CATCHUP";
private static final String DESCRIPTION = "Catches up and publishes all Events missing from the View Store";

public EventCatchupCommand() {
super(CATCHUP, DESCRIPTION);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package uk.gov.justice.services.eventstore.management.commands;

import uk.gov.justice.services.jmx.api.command.BaseSystemCommand;

public class IndexerCatchupCommand extends BaseSystemCommand implements CatchupCommand {

public static final String INDEXER_CATCHUP = "INDEXER_CATCHUP";
private static final String DESCRIPTION = "Rebuilds the application search indexes";

public IndexerCatchupCommand() {
super(INDEXER_CATCHUP, DESCRIPTION);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package uk.gov.justice.services.eventstore.management.commands;

import uk.gov.justice.services.jmx.api.command.SystemCommand;

public interface PublishingCommand extends SystemCommand {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package uk.gov.justice.services.eventstore.management.commands;

import uk.gov.justice.services.jmx.api.command.BaseSystemCommand;

public class RebuildCommand extends BaseSystemCommand {

public static final String REBUILD = "REBUILD";
private static final String DESCRIPTION = "Rebuilds PublishedEvents and renumbers the Events";

public RebuildCommand() {
super(REBUILD, DESCRIPTION);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package uk.gov.justice.services.eventstore.management.commands;

import uk.gov.justice.services.jmx.api.command.BaseSystemCommand;

public class RemoveTriggerCommand extends BaseSystemCommand {

public static final String REMOVE_TRIGGER = "REMOVE_TRIGGER";
private static final String DESCRIPTION = "Removes the 'queue_publish_event' trigger from the event log table so that new events inserted into the event_log table will no longer trigger publishing.";

public RemoveTriggerCommand() {
super(REMOVE_TRIGGER, DESCRIPTION);
}
}
Loading

0 comments on commit 45b9c9a

Please sign in to comment.