Change EventListener functions to non-blocking scope 71/110571/2
authorJozsef Csongvai <jozsef.csongvai@bell.ca>
Fri, 24 Jul 2020 17:11:39 +0000 (13:11 -0400)
committerJozsef Csongvai <jozsef.csongvai@bell.ca>
Fri, 24 Jul 2020 19:06:53 +0000 (19:06 +0000)
BluePrintProcessingKafkaConsumer and BluePrintProcessorCluster were
both defining EventListener functions which were executed with
runBlocking. When both were enabled, kafkaconsumer would block
and cluster would never run.

Issue-ID: CCSDK-2609
Signed-off-by: Jozsef Csongvai <jozsef.csongvai@bell.ca>
Change-Id: I91813208f0474869f174da6c99280b5159859232

ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/BluePrintProcessorCluster.kt
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingKafkaConsumer.kt

index 2284a6f..513bd51 100644 (file)
@@ -16,7 +16,8 @@
 
 package org.onap.ccsdk.cds.blueprintsprocessor
 
-import kotlinx.coroutines.runBlocking
+import kotlinx.coroutines.GlobalScope
+import kotlinx.coroutines.launch
 import org.onap.ccsdk.cds.blueprintsprocessor.core.service.BluePrintClusterService
 import org.onap.ccsdk.cds.blueprintsprocessor.core.service.ClusterInfo
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
@@ -57,7 +58,7 @@ open class BluePrintProcessorCluster(private val bluePrintClusterService: BluePr
     private val log = logger(BluePrintProcessorCluster::class)
 
     @EventListener(ApplicationReadyEvent::class)
-    fun startAndJoinCluster() = runBlocking {
+    fun startAndJoinCluster() = GlobalScope.launch {
 
         if (BluePrintConstants.CLUSTER_ENABLED) {
 
index a95af81..1f3dd65 100644 (file)
@@ -16,6 +16,7 @@
 
 package org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api
 
+import kotlinx.coroutines.GlobalScope
 import kotlinx.coroutines.channels.consumeEach
 import kotlinx.coroutines.launch
 import kotlinx.coroutines.runBlocking
@@ -55,7 +56,7 @@ open class BluePrintProcessingKafkaConsumer(
     }
 
     @EventListener(ApplicationReadyEvent::class)
-    fun setupMessageListener() = runBlocking {
+    fun setupMessageListener() = GlobalScope.launch {
         try {
             log.info(
                 "Setting up message consumer($CONSUMER_SELECTOR)" +