Skip to content
This repository has been archived by the owner on Aug 13, 2020. It is now read-only.

Commit

Permalink
Merge pull request #797 from CJSCommonPlatform/change-event-error-log…
Browse files Browse the repository at this point in the history
…-primary-key

Make the primary key of event-error-log to be composite
  • Loading branch information
mapingo committed Dec 16, 2019
2 parents 6418af9 + 2a72f96 commit 5589042
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 60 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ on [Keep a CHANGELOG](http://keepachangelog.com/). This project adheres to

## [Unreleased]

## [6.5.0-M1] - 2019-12-16
- Update framework-api to 4.2.0
## [6.5.0-M3] - 2019-12-16
- Update framework-api to 4.2.1
- Add table in system database 'event_error_log' for storing errors with events that failed to process
- New SystemErrorService for reporting system errors

Expand Down
1 change: 0 additions & 1 deletion framework-system/framework-system-errors/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
<dependency>
<groupId>uk.gov.justice.framework-api</groupId>
<artifactId>framework-api-system-errors</artifactId>
<version>${framework-api.version}</version>
</dependency>
<dependency>
<groupId>uk.gov.justice.framework-api</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ public void reportError(
final Optional<Long> eventNumber = metadata.eventNumber();

final EventError eventError = new EventError(
messageId,
componentName,
eventId,
eventNumber.orElse(MISSING_EVENT_NUMBER),
componentName,
messageId,
metadata.asJsonObject().toString(),
jsonEnvelope.payload().toString(),
exception.getMessage(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
logicalFilePath="004-add-event-handling-error-log-table.xml">

<createTable tableName="event_error_log">
<column name="event_id" type="uuid">
<column name="message_id" type="TEXT">
<constraints nullable="false"/>
</column>
<column name="event_number" type="BIGINT">
<column name="component" type="TEXT">
<constraints nullable="false"/>
</column>
<column name="component" type="TEXT">
<column name="event_id" type="uuid">
<constraints nullable="false"/>
</column>
<column name="message_id" type="TEXT">
<column name="event_number" type="BIGINT">
<constraints nullable="false"/>
</column>
<column name="metadata" type="TEXT">
Expand All @@ -37,9 +37,12 @@
<column name="errored_at" type="TIMESTAMP WITH TIME ZONE">
<constraints nullable="false"/>
</column>
<column name="comments" type="TEXT">
<constraints nullable="true"/>
</column>
</createTable>

<addPrimaryKey tableName="event_error_log" columnNames="event_id"/>
<addPrimaryKey tableName="event_error_log" columnNames="message_id,component"/>

<rollback>
<dropTable tableName="event_error_log"/>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

public class EventError {

private final String messageId;
private final String component;
private final UUID eventId;
private final Long eventNumber;
private final String component;
private final String messageId;
private final String metadata;
private final String payload;
private final String errorMessage;
Expand All @@ -18,20 +18,20 @@ public class EventError {
private final String comments;

public EventError(
final String messageId,
final String component,
final UUID eventId,
final Long eventNumber,
final String component,
final String messageId,
final String metadata,
final String payload,
final String errorMessage,
final String stacktrace,
final ZonedDateTime erroredAt,
final String comments) {
this.messageId = messageId;
this.component = component;
this.eventId = eventId;
this.eventNumber = eventNumber;
this.component = component;
this.messageId = messageId;
this.metadata = metadata;
this.payload = payload;
this.errorMessage = errorMessage;
Expand All @@ -40,20 +40,20 @@ public EventError(
this.comments = comments;
}

public UUID getEventId() {
return eventId;
}

public Long getEventNumber() {
return eventNumber;
public String getMessageId() {
return messageId;
}

public String getComponent() {
return component;
}

public String getMessageId() {
return messageId;
public UUID getEventId() {
return eventId;
}

public Long getEventNumber() {
return eventNumber;
}

public String getMetadata() {
Expand Down Expand Up @@ -85,10 +85,10 @@ public boolean equals(final Object o) {
if (this == o) return true;
if (!(o instanceof EventError)) return false;
final EventError that = (EventError) o;
return Objects.equals(eventId, that.eventId) &&
Objects.equals(eventNumber, that.eventNumber) &&
return Objects.equals(messageId, that.messageId) &&
Objects.equals(component, that.component) &&
Objects.equals(messageId, that.messageId) &&
Objects.equals(eventId, that.eventId) &&
Objects.equals(eventNumber, that.eventNumber) &&
Objects.equals(metadata, that.metadata) &&
Objects.equals(payload, that.payload) &&
Objects.equals(errorMessage, that.errorMessage) &&
Expand All @@ -99,16 +99,16 @@ public boolean equals(final Object o) {

@Override
public int hashCode() {
return Objects.hash(eventId, eventNumber, component, messageId, metadata, payload, errorMessage, stacktrace, erroredAt, comments);
return Objects.hash(messageId, component, eventId, eventNumber, metadata, payload, errorMessage, stacktrace, erroredAt, comments);
}

@Override
public String toString() {
return "EventError{" +
"eventId=" + eventId +
", eventNumber=" + eventNumber +
"messageId='" + messageId + '\'' +
", component='" + component + '\'' +
", messageId='" + messageId + '\'' +
", eventId=" + eventId +
", eventNumber=" + eventNumber +
", metadata='" + metadata + '\'' +
", payload='" + payload + '\'' +
", errorMessage='" + errorMessage + '\'' +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ public List<EventError> findAll() {
final String comment = resultSet.getString("comments");

final EventError eventError = new EventError(
messageId,
component,
eventId,
eventNumber,
component,
messageId,
metadata,
payload,
errorMessage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ public void shouldStoreEventErrorLog() throws Exception {
final ZonedDateTime then = now.plusSeconds(23);

final EventError eventError_1 = new EventError(
"messageId_1",
"component_1",
randomUUID(),
1L,
"component_1",
"messageId_1",
"metadata_1",
"payload_1",
"errorMessage_1",
Expand All @@ -57,10 +57,10 @@ public void shouldStoreEventErrorLog() throws Exception {
"comment_1"
);
final EventError eventError_2 = new EventError(
"messageId_2",
"component_2",
randomUUID(),
2L,
"component_2",
"messageId_2",
"metadata_2",
"payload_2",
"errorMessage_2",
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

<common-bom.version>2.4.0</common-bom.version>
<test-utils.version>1.24.3</test-utils.version>
<framework-api.version>4.2.0</framework-api.version>
<framework-api.version>4.2.1</framework-api.version>
<utilities.version>1.20.3</utilities.version>
<json-schema-catalog.version>1.7.6</json-schema-catalog.version>
<embedded-artemis.version>1.2.0</embedded-artemis.version>
Expand Down

0 comments on commit 5589042

Please sign in to comment.