Skip to content

Commit

Permalink
Merge branch 'main' into platform/bill/16144
Browse files Browse the repository at this point in the history
  • Loading branch information
arnejduranovic authored Nov 21, 2024
2 parents 7ce035d + 9258b5d commit 7f92ba3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy_terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,4 @@ jobs:
terraform validate
terraform fmt -recursive
terraform plan -out ${{ needs.pre_job.outputs.env_name }}-tf.plan
# terraform apply -input=false -no-color -lock-timeout=600s -auto-approve ${{ needs.pre_job.outputs.env_name }}-tf.plan
terraform apply -input=false -no-color -lock-timeout=600s -auto-approve ${{ needs.pre_job.outputs.env_name }}-tf.plan
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import gov.cdc.prime.router.report.ReportService
import org.apache.commons.lang3.StringUtils
import org.apache.logging.log4j.kotlin.Logging
import org.jooq.exception.DataAccessException
import java.util.Base64

class FHIRFunctions(
private val workflowEngine: WorkflowEngine = WorkflowEngine(),
Expand Down Expand Up @@ -204,7 +205,7 @@ class FHIRFunctions(
} catch (ex: SubmissionSenderNotFound) {
// This is a specific error case that can occur while handling a report via the new Submission service
// In a situation that the sender is not found there is not enough information to record a report event
// and we want a poison queue message to be immediately added so that the configuration can be fixed
// so, we want a poison queue message to be immediately added so that the configuration can be fixed
logger.error(ex)
val tableEntity = Submission(
ex.reportId.toString(),
Expand All @@ -213,14 +214,16 @@ class FHIRFunctions(
actionLogger.errors.takeIf { it.isNotEmpty() }?.map { it.detail.message }?.toString()
)
submissionTableService.insertSubmission(tableEntity)
queueAccess.sendMessage("${messageContent.messageQueueName}-poison", message)
val encodedMsg = Base64.getEncoder().encodeToString(message.toByteArray())
queueAccess.sendMessage("${messageContent.messageQueueName}-poison", encodedMsg)
return emptyList()
} catch (ex: Exception) {
// We're catching anything else that occurs because the most likely cause is a code or configuration error
// that will not be resolved if the message is automatically retried
// Instead, the error is recorded as an event and message is manually inserted into the poison queue
val report = databaseAccess.fetchReportFile(messageContent.reportId)
val poisonQueueMessageId = queueAccess.sendMessage("${messageContent.messageQueueName}-poison", message)
val encodedMsg = Base64.getEncoder().encodeToString(message.toByteArray())
val poisonQueueMessageId = queueAccess.sendMessage("${messageContent.messageQueueName}-poison", encodedMsg)
fhirEngine.reportEventService.sendReportProcessingError(
ReportStreamEventName.PIPELINE_EXCEPTION,
report,
Expand Down
5 changes: 3 additions & 2 deletions prime-router/src/test/kotlin/azure/FHIRFunctionsTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import org.jooq.tools.jdbc.MockResult
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import java.util.Base64
import java.util.UUID

class FHIRFunctionsTests {
Expand Down Expand Up @@ -98,7 +99,7 @@ class FHIRFunctionsTests {
verify(exactly = 1) {
QueueAccess.sendMessage(
"${QueueMessage.elrConvertQueueName}-poison",
queueMessage
Base64.getEncoder().encodeToString(queueMessage.toByteArray())
)
mockReportEventService.sendReportProcessingError(
ReportStreamEventName.PIPELINE_EXCEPTION,
Expand All @@ -124,7 +125,7 @@ class FHIRFunctionsTests {
verify(exactly = 0) {
QueueAccess.sendMessage(
"${QueueMessage.elrConvertQueueName}-poison",
queueMessage
Base64.getEncoder().encodeToString(queueMessage.toByteArray())
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ import tech.tablesaw.api.StringColumn
import tech.tablesaw.api.Table
import java.nio.charset.Charset
import java.time.OffsetDateTime
import java.util.Base64
import java.util.UUID

@Testcontainers
Expand Down Expand Up @@ -334,8 +335,7 @@ class FHIRConverterIntegrationTests {
verify(exactly = 1) {
QueueAccess.sendMessage(
"${QueueMessage.elrSubmissionConvertQueueName}-poison",
queueMessage

Base64.getEncoder().encodeToString(queueMessage.toByteArray())
)
}
}
Expand Down

0 comments on commit 7f92ba3

Please sign in to comment.