Skip to content

Commit

Permalink
Merge cc518fd into 18a50a4
Browse files Browse the repository at this point in the history
  • Loading branch information
allanmckenzie committed Aug 26, 2021
2 parents 18a50a4 + cc518fd commit 4ab239a
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on [Keep a CHANGELOG](http://keepachangelog.com/). This project adheres to

### Changed
- Updated to java 11 and OpenJdk
- Removed trigger from the event publishing process
- Updated wildfly to 20.0.1-Final
- Reduced the maximum runtime for each iteration of the publishing beans in the IT tests to 450 milliseconds
- Update to maven-framework-parent-pom 11.0.0-M1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package uk.gov.justice.services.example.cakeshop.it;

import static java.lang.Integer.parseInt;
import static java.lang.Integer.valueOf;
import static java.lang.String.format;
import static java.lang.System.getProperty;
Expand Down Expand Up @@ -49,7 +50,7 @@ public class CatchupPerformanceIT {
private final ProcessedEventCounter processedEventCounter = new ProcessedEventCounter(viewStoreDataSource);

private static final String HOST = getHost();
private static final int PORT = valueOf(getProperty("random.management.port"));
private static final int PORT = parseInt(getProperty("random.management.port"));

private final TestSystemCommanderClientFactory systemCommanderClientFactory = new TestSystemCommanderClientFactory();
private final DatabaseCleaner databaseCleaner = new DatabaseCleaner();
Expand Down Expand Up @@ -157,6 +158,7 @@ private void addEventsToEventLog(final int numberOfStreams, final int numberOfEv

batchEventInserter.updateEventStreamTable(streamIds);
batchEventInserter.updateEventLogTable(events);
batchEventInserter.updatePublishQueueTableWithEvents(events);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ private void addEventsToEventLog(final int numberOfStreams, final int numberOfEv

batchEventInserter.updateEventStreamTable(streamIds);
batchEventInserter.updateEventLogTable(events);
batchEventInserter.updatePublishQueueTableWithEvents(events);
}

private void setPayloadsOfEventsInvalid() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static uk.gov.justice.services.eventstore.management.commands.AddTriggerCommand.ADD_TRIGGER;
import static uk.gov.justice.services.eventstore.management.commands.DisablePublishingCommand.DISABLE_PUBLISHING;
import static uk.gov.justice.services.eventstore.management.commands.EnablePublishingCommand.ENABLE_PUBLISHING;
import static uk.gov.justice.services.eventstore.management.commands.EventCatchupCommand.CATCHUP;
import static uk.gov.justice.services.eventstore.management.commands.IndexerCatchupCommand.INDEXER_CATCHUP;
import static uk.gov.justice.services.eventstore.management.commands.RebuildCommand.REBUILD;
import static uk.gov.justice.services.eventstore.management.commands.RemoveTriggerCommand.REMOVE_TRIGGER;
import static uk.gov.justice.services.eventstore.management.commands.ValidatePublishedEventsCommand.VALIDATE_EVENTS;
import static uk.gov.justice.services.eventstore.management.commands.VerifyCatchupCommand.VERIFY_CATCHUP;
import static uk.gov.justice.services.eventstore.management.commands.VerifyRebuildCommand.VERIFY_REBUILD;
Expand Down Expand Up @@ -55,21 +53,19 @@ public void shouldListAllSystemCommands() throws Exception {
.getRemote(CONTEXT_NAME)
.listCommands();

assertThat(systemCommandDetailsList.size(), is(14));
assertThat(systemCommandDetailsList.size(), is(12));

final Map<String, SystemCommandDetails> systemCommandDetailsMap = systemCommandDetailsList
.stream()
.collect(toMap(SystemCommandDetails::getName, systemCommandDetails -> systemCommandDetails));

assertThat(systemCommandDetailsMap.get(ADD_TRIGGER), is(notNullValue()));
assertThat(systemCommandDetailsMap.get(DISABLE_PUBLISHING), is(notNullValue()));
assertThat(systemCommandDetailsMap.get(ENABLE_PUBLISHING), is(notNullValue()));
assertThat(systemCommandDetailsMap.get(CATCHUP), is(notNullValue()));
assertThat(systemCommandDetailsMap.get(INDEXER_CATCHUP), is(notNullValue()));
assertThat(systemCommandDetailsMap.get(PING), is(notNullValue()));
assertThat(systemCommandDetailsMap.get(REBUILD), is(notNullValue()));
assertThat(systemCommandDetailsMap.get(REFRESH_FEATURE_CACHE), is(notNullValue()));
assertThat(systemCommandDetailsMap.get(REMOVE_TRIGGER), is(notNullValue()));
assertThat(systemCommandDetailsMap.get(SUSPEND), is(notNullValue()));
assertThat(systemCommandDetailsMap.get(UNSUSPEND), is(notNullValue()));
assertThat(systemCommandDetailsMap.get(VALIDATE_EVENTS), is(notNullValue()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public class BatchEventInserter {
private static final String SQL_INSERT_STREAM = "INSERT INTO event_stream " +
"(stream_id, date_created, active) values (?, ?, ?)";

private static final String SQL_INSERT_EVENT_INTO_PUBLISH_QUEUE = "INSERT INTO pre_publish_queue " +
"(event_log_id, date_queued) values (?, ?)";

private final DataSource eventStoreDataSource;
private final int batchSize;

Expand Down Expand Up @@ -80,4 +83,24 @@ public void updateEventStreamTable(final List<UUID> streamIds) throws Exception
preparedStatement.executeBatch();
}
}

public void updatePublishQueueTableWithEvents(final List<Event> events) throws Exception {

try (final Connection connection = eventStoreDataSource.getConnection();
final PreparedStatement preparedStatement = connection.prepareStatement(SQL_INSERT_EVENT_INTO_PUBLISH_QUEUE)) {
for (int i = 0; i < events.size(); i++) {
final UUID eventId = events.get(i).getId();
preparedStatement.setObject(1, eventId);
preparedStatement.setTimestamp(2, toSqlTimestamp(clock.now()));

preparedStatement.addBatch();

if (i % batchSize == 0) {
preparedStatement.executeBatch();
}
}

preparedStatement.executeBatch();
}
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

<framework-libraries.version>11.0.0-M7</framework-libraries.version>
<framework.version>11.0.0-M6</framework.version>
<event-store.version>11.0.0-M7</event-store.version>
<event-store.version>11.0.0-M8</event-store.version>

<jee.api.version>8.0</jee.api.version>
</properties>
Expand Down

0 comments on commit 4ab239a

Please sign in to comment.