Skip to content

Commit

Permalink
Update FHIRFunctions to base64 encode messages going to poison queue (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
arnejduranovic authored Nov 20, 2024
1 parent 448460a commit d420f0b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
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 @@ -220,7 +221,8 @@ class FHIRFunctions(
// 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

0 comments on commit d420f0b

Please sign in to comment.