Skip to content

Commit

Permalink
Fixed startup issue with AWS SNS/SQS message system
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt B Krystof committed Jan 16, 2025
1 parent 1fa57db commit 10ea2aa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class HealthCheckAWSSQS(
}.await()
}
result.onFailure { error ->
val reason = "AWS SQS is not healthy ${error.localizedMessage}"
val reason = "AWS SQS is not healthy: ${error.localizedMessage}"
logger.error(reason)
return HealthCheckResult(service, HealthStatusType.STATUS_DOWN, reason)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import gov.cdc.ocio.types.health.HealthCheckSystem
* @property healthCheckSystem HealthCheckSystem
* @constructor
*/
class AWSSQSMessageSystem(sqsClient: SqsClient, queueUrl: String): MessageSystem {
class AWSSQSMessageSystem(val sqsClient: SqsClient, queueUrl: String): MessageSystem {

override var healthCheckSystem = HealthCheckAWSSQS(sqsClient, queueUrl) as HealthCheckSystem
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import aws.sdk.kotlin.runtime.auth.credentials.StaticCredentialsProvider
import aws.sdk.kotlin.services.sqs.SqsClient
import aws.sdk.kotlin.services.sqs.model.*
import aws.smithy.kotlin.runtime.net.url.Url
import gov.cdc.ocio.processingstatusapi.messagesystems.AWSSQSMessageSystem
import gov.cdc.ocio.processingstatusapi.messagesystems.MessageSystem

import gov.cdc.ocio.processingstatusapi.utils.SchemaValidation
import io.ktor.server.application.*
Expand All @@ -17,7 +19,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import org.apache.qpid.proton.TimeoutException
import org.koin.java.KoinJavaComponent.inject
import org.koin.java.KoinJavaComponent.getKoin
import software.amazon.awssdk.auth.credentials.WebIdentityTokenFileCredentialsProvider
import java.nio.file.Path

Expand Down Expand Up @@ -66,7 +68,8 @@ val AWSSQSPlugin = createApplicationPlugin(
configurationPath = "aws",
createConfiguration = ::AWSSQSServiceConfiguration
) {
val sqsClient by inject<SqsClient>(SqsClient::class.java)

lateinit var sqsClient: SqsClient

lateinit var queueUrl: String

Expand Down Expand Up @@ -164,6 +167,8 @@ val AWSSQSPlugin = createApplicationPlugin(

on(MonitoringEvent(ApplicationStarted)) { application ->
application.log.info("Application started successfully.")
val msgSystem = getKoin().get<MessageSystem>() as AWSSQSMessageSystem
sqsClient = msgSystem.sqsClient
consumeMessages()
}

Expand Down

0 comments on commit 10ea2aa

Please sign in to comment.