Skip to content

Commit

Permalink
fix stovelistener for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
osoykan committed May 1, 2024
1 parent a67a121 commit 1bdb6d1
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ abstract class StoveListener(
suspend fun start() {
consumer.subscribe(listOf(topicDefinition.topic, topicDefinition.retryTopic, topicDefinition.deadLetterTopic))
consuming = GlobalScope.launch {
while (!consuming.isCancelled) {
while (!this.isActive) {
consumer
.poll(Duration.ofMillis(100))
.forEach { message ->
Expand Down Expand Up @@ -84,7 +84,7 @@ abstract class StoveListener(

abstract suspend fun listen(record: ConsumerRecord<String, String>)

override fun close() {
Try { consuming.cancel() }
override fun close(): Unit = runBlocking {
Try { consuming.cancelAndJoin() }
}
}

0 comments on commit 1bdb6d1

Please sign in to comment.