This commit is contained in:
+9
-1
@@ -49,7 +49,8 @@ class GameResultStreamListener:
|
||||
case Success(_) => ()
|
||||
|
||||
private def pollLoop(): Unit =
|
||||
while true do
|
||||
var running = true
|
||||
while running do
|
||||
Try {
|
||||
val messages = redis.stream(classOf[String]).xreadgroup(
|
||||
groupName,
|
||||
@@ -60,9 +61,16 @@ class GameResultStreamListener:
|
||||
)
|
||||
if messages != null then messages.forEach(msg => handleMessage(msg))
|
||||
} match
|
||||
case Failure(ex) if isInterrupted(ex) =>
|
||||
Thread.currentThread().interrupt()
|
||||
running = false
|
||||
case Failure(ex) => log.warnf(ex, "Error in result poll loop")
|
||||
case Success(_) => ()
|
||||
|
||||
private def isInterrupted(ex: Throwable): Boolean =
|
||||
ex.isInstanceOf[InterruptedException] ||
|
||||
(ex.getCause != null && ex.getCause.isInstanceOf[InterruptedException])
|
||||
|
||||
private def handleMessage(msg: StreamMessage[String, String, String]): Unit =
|
||||
val json = msg.payload().get("data")
|
||||
Try(objectMapper.readValue(json, classOf[GameWritebackEventDto])) match
|
||||
|
||||
Reference in New Issue
Block a user