File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
src/main/kotlin/net/leanix/githubagent Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -14,4 +14,8 @@ class GraphQLApiException(errors: List<GraphQLClientError>) :
1414class WebhookSecretNotSetException : RuntimeException (" Webhook secret not set" )
1515class InvalidEventSignatureException : RuntimeException (" Invalid event signature" )
1616class ManifestFileNotFoundException : RuntimeException (" Manifest File Not Found" )
17- class UnableToSendMessageException : RuntimeException (" Unable to send message to the backend" )
17+ class UnableToSendMessageException (exception : Exception ) :
18+ RuntimeException (
19+ " Unable to send message to the backend" ,
20+ exception
21+ )
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import net.leanix.githubagent.shared.TOPIC_PREFIX
88import org.slf4j.LoggerFactory
99import org.springframework.messaging.simp.stomp.StompSession
1010import org.springframework.stereotype.Service
11+ import java.util.concurrent.locks.ReentrantLock
1112
1213@Service
1314class WebSocketService (
@@ -18,6 +19,7 @@ class WebSocketService(
1819
1920 private val logger = LoggerFactory .getLogger(WebSocketService ::class .java)
2021 var stompSession: StompSession ? = null
22+ private val stompSendLock = ReentrantLock ()
2123
2224 fun initSession () {
2325 logger.info(" Initializing websocket session" )
@@ -35,10 +37,13 @@ class WebSocketService(
3537 if (! brokerStompSessionHandler.isConnected() && cachingService.get(" runId" ) == null ) {
3638 return
3739 }
38- runCatching {
40+ stompSendLock.lock()
41+ try {
3942 stompSession!! .send(" $TOPIC_PREFIX$topic " , data)
40- }.onFailure {
41- throw UnableToSendMessageException ()
43+ } catch (e: Exception ) {
44+ throw UnableToSendMessageException (e)
45+ } finally {
46+ stompSendLock.unlock()
4247 }
4348 }
4449}
You can’t perform that action at this time.
0 commit comments