diff --git a/CHANGELOG.md b/CHANGELOG.md index ad33d952c..8338fa82b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] +### Fixed + +* Add additional error handling for exceptions raised when processing PSS queue, and MHS queue messages. +* Fix bug in some SQL statement which caused excessively large amounts of data to be returned, sometimes resulting in a PostgresSQL Out of Memory error. + ## [0.15] - 2023-10-24 * Fixed issue with some `ObservationStatement` coded as blood pressure readings not being output into Bundle. diff --git a/db-connector/src/main/java/uk/nhs/adaptors/connector/config/DbConnectorConfiguration.java b/db-connector/src/main/java/uk/nhs/adaptors/connector/config/DbConnectorConfiguration.java index c1ad358a5..5f4ca77a7 100644 --- a/db-connector/src/main/java/uk/nhs/adaptors/connector/config/DbConnectorConfiguration.java +++ b/db-connector/src/main/java/uk/nhs/adaptors/connector/config/DbConnectorConfiguration.java @@ -1,16 +1,12 @@ package uk.nhs.adaptors.connector.config; -import java.time.temporal.ChronoUnit; import java.util.List; import javax.sql.DataSource; -import lombok.extern.slf4j.Slf4j; import org.jdbi.v3.core.Jdbi; import org.jdbi.v3.core.mapper.RowMapper; import org.jdbi.v3.core.spi.JdbiPlugin; -import org.jdbi.v3.core.statement.SqlLogger; -import org.jdbi.v3.core.statement.StatementContext; import org.jdbi.v3.postgres.PostgresPlugin; import org.jdbi.v3.sqlobject.SqlObjectPlugin; import org.springframework.boot.autoconfigure.domain.EntityScan; @@ -19,12 +15,13 @@ import org.springframework.context.annotation.Configuration; import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy; +import lombok.extern.slf4j.Slf4j; import uk.nhs.adaptors.connector.dao.ImmunizationSnomedCTDao; import uk.nhs.adaptors.connector.dao.MessagePersistDurationDao; import uk.nhs.adaptors.connector.dao.MigrationStatusLogDao; +import uk.nhs.adaptors.connector.dao.PatientAttachmentLogDao; import uk.nhs.adaptors.connector.dao.PatientMigrationRequestDao; import uk.nhs.adaptors.connector.dao.SnomedCTDao; -import uk.nhs.adaptors.connector.dao.PatientAttachmentLogDao; @Slf4j @Configuration @@ -37,15 +34,6 @@ public Jdbi jdbi(DataSource ds, List jdbiPlugins, List> TransactionAwareDataSourceProxy proxy = new TransactionAwareDataSourceProxy(ds); Jdbi jdbi = Jdbi.create(proxy); - SqlLogger sqlLogger = new SqlLogger() { - @Override - public void logAfterExecution(StatementContext context) { - LOGGER.debug("sql {}, parameters {}, timeTaken {} ms", context.getRenderedSql(), - context.getBinding().toString(), context.getElapsedTime(ChronoUnit.MILLIS)); - } - }; - jdbi.setSqlLogger(sqlLogger); - jdbiPlugins.forEach(jdbi::installPlugin); rowMappers.forEach(jdbi::registerRowMapper); return jdbi; diff --git a/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/amqp/JmsListenerErrorHandler.java b/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/amqp/JmsListenerErrorHandler.java index 507bd1426..ea4dce9c1 100644 --- a/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/amqp/JmsListenerErrorHandler.java +++ b/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/amqp/JmsListenerErrorHandler.java @@ -18,14 +18,27 @@ public class JmsListenerErrorHandler implements ErrorHandler { WebClientRequestException.class, "Unable to connect to MHS" ); + /** + * Increment the delivery count for all exceptions, except for RETRYABLE_EXCEPTION_MESSAGES which are retried indefinitely. + * See AbstractMessageListenerContainer + * for documentation. + */ @Override public void handleError(Throwable t) { + LOGGER.warn("Handling JMS message error due to [{}] with message [{}]", t.getClass(), t.getMessage()); + t.printStackTrace(); + Throwable cause = t.getCause(); - Class classOfCause = cause.getClass(); + if (cause == null) { + return; + } + Class classOfCause = cause.getClass(); LOGGER.warn("Caught Error cause of type: [{}], with message: [{}]", classOfCause.toString(), cause.getMessage()); + // Rety these specific exceptions continuously until they stop happening. + // These retries will happen until the associated transfer times out. if (RETRYABLE_EXCEPTION_MESSAGES.containsKey(classOfCause)) { throw new RuntimeException(RETRYABLE_EXCEPTION_MESSAGES.get(classOfCause)); }