Skip to content

Commit 5fea9f0

Browse files
committed
PI-2938 Ignore exception when message has been acknowledged
1 parent f15a846 commit 5fea9f0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/listener/AwsNotificationListener.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package uk.gov.justice.digital.hmpps.listener
22

33
import com.fasterxml.jackson.databind.ObjectMapper
44
import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
5+
import io.awspring.cloud.sqs.SqsException
56
import io.awspring.cloud.sqs.annotation.SqsListener
67
import io.awspring.cloud.sqs.listener.AsyncAdapterBlockingExecutionFailedException
78
import io.awspring.cloud.sqs.listener.ListenerExecutionFailedException
@@ -76,8 +77,10 @@ class AwsNotificationListener(
7677
try {
7778
visibility.changeTo(30)
7879
} catch (e: Exception) {
79-
telemetryService.trackException(e)
80-
Sentry.captureException(e)
80+
if (e.cause !is SqsException || e.cause?.message?.contains(MESSAGE_ACKNOWLEDGED) != true) {
81+
telemetryService.trackException(e)
82+
Sentry.captureException(e)
83+
}
8184
}
8285
}, Duration.ofSeconds(visibilityExtensionInterval))
8386
}
@@ -105,6 +108,7 @@ class AwsNotificationListener(
105108
}
106109

107110
companion object {
111+
const val MESSAGE_ACKNOWLEDGED = "Message does not exist or is not available for visibility timeout change"
108112
val RETRYABLE_EXCEPTIONS = listOf(
109113
RestClientException::class,
110114
CancellationException::class,

0 commit comments

Comments
 (0)