Skip to content

Commit d420f0b

Browse files
Update FHIRFunctions to base64 encode messages going to poison queue (#16611)
1 parent 448460a commit d420f0b

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

prime-router/src/main/kotlin/fhirengine/azure/FHIRFunctions.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import gov.cdc.prime.router.report.ReportService
3434
import org.apache.commons.lang3.StringUtils
3535
import org.apache.logging.log4j.kotlin.Logging
3636
import org.jooq.exception.DataAccessException
37+
import java.util.Base64
3738

3839
class FHIRFunctions(
3940
private val workflowEngine: WorkflowEngine = WorkflowEngine(),
@@ -204,7 +205,7 @@ class FHIRFunctions(
204205
} catch (ex: SubmissionSenderNotFound) {
205206
// This is a specific error case that can occur while handling a report via the new Submission service
206207
// In a situation that the sender is not found there is not enough information to record a report event
207-
// and we want a poison queue message to be immediately added so that the configuration can be fixed
208+
// so, we want a poison queue message to be immediately added so that the configuration can be fixed
208209
logger.error(ex)
209210
val tableEntity = Submission(
210211
ex.reportId.toString(),
@@ -220,7 +221,8 @@ class FHIRFunctions(
220221
// that will not be resolved if the message is automatically retried
221222
// Instead, the error is recorded as an event and message is manually inserted into the poison queue
222223
val report = databaseAccess.fetchReportFile(messageContent.reportId)
223-
val poisonQueueMessageId = queueAccess.sendMessage("${messageContent.messageQueueName}-poison", message)
224+
val encodedMsg = Base64.getEncoder().encodeToString(message.toByteArray())
225+
val poisonQueueMessageId = queueAccess.sendMessage("${messageContent.messageQueueName}-poison", encodedMsg)
224226
fhirEngine.reportEventService.sendReportProcessingError(
225227
ReportStreamEventName.PIPELINE_EXCEPTION,
226228
report,

prime-router/src/test/kotlin/azure/FHIRFunctionsTests.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import org.jooq.tools.jdbc.MockResult
2727
import org.junit.jupiter.api.BeforeEach
2828
import org.junit.jupiter.api.Test
2929
import org.junit.jupiter.api.assertThrows
30+
import java.util.Base64
3031
import java.util.UUID
3132

3233
class FHIRFunctionsTests {
@@ -98,7 +99,7 @@ class FHIRFunctionsTests {
9899
verify(exactly = 1) {
99100
QueueAccess.sendMessage(
100101
"${QueueMessage.elrConvertQueueName}-poison",
101-
queueMessage
102+
Base64.getEncoder().encodeToString(queueMessage.toByteArray())
102103
)
103104
mockReportEventService.sendReportProcessingError(
104105
ReportStreamEventName.PIPELINE_EXCEPTION,
@@ -124,7 +125,7 @@ class FHIRFunctionsTests {
124125
verify(exactly = 0) {
125126
QueueAccess.sendMessage(
126127
"${QueueMessage.elrConvertQueueName}-poison",
127-
queueMessage
128+
Base64.getEncoder().encodeToString(queueMessage.toByteArray())
128129
)
129130
}
130131
}

0 commit comments

Comments
 (0)